Пример #1
0
/**
 * Allocates a single random object in the dungeon.
 * \param c the current chunk
 * \param set where the entity is placed (corridor, room or either)
 * \param typ what is placed (rubble, trap, gold, item)
 * \param depth generation depth
 * \param origin item origin (if appropriate)
 *
 * 'set' controls where the object is placed (corridor, room, either).
 * 'typ' conrols the kind of object (rubble, trap, gold, item).
 */
bool alloc_object(struct chunk *c, int set, int typ, int depth, byte origin)
{
    int x = 0, y = 0;
    int tries = 0;

    /* Pick a "legal" spot */
    while (tries < 2000) {
		tries++;

		find_empty(c, &y, &x);

		/* If we are ok with a corridor and we're in one, we're done */
		if (set & SET_CORR && !square_isroom(c, y, x)) break;

		/* If we are ok with a room and we're in one, we're done */
		if (set & SET_ROOM && square_isroom(c, y, x)) break;
    }

    if (tries == 2000) return false;

    /* Place something */
    switch (typ) {
    case TYP_RUBBLE: place_rubble(c, y, x); break;
    case TYP_TRAP: place_trap(c, y, x, -1, depth); break;
    case TYP_GOLD: place_gold(c, y, x, depth, origin); break;
    case TYP_OBJECT: place_object(c, y, x, depth, false, false, origin, 0); break;
    case TYP_GOOD: place_object(c, y, x, depth, true, false, origin, 0); break;
    case TYP_GREAT: place_object(c, y, x, depth, true, true, origin, 0); break;
    }
    return true;
}
Пример #2
0
int PlaceHostage()	{
	int ctype,i;
	vms_vector	cur_object_loc;

	//update_due_to_new_segment();
	compute_segment_center(&cur_object_loc, Cursegp);

	ctype = -1;
	for (i=0; i<Num_total_object_types; i++ )	{
		if (ObjType[i] == OL_HOSTAGE )	{
			ctype = i;	
			break;
		}
	}

	Assert( ctype != -1 );

	if (place_object(Cursegp, &cur_object_loc, ctype )==0)	{
		Int3();		// Debug below
		i=place_object(Cursegp, &cur_object_loc, ctype );
		return 1;
	}

	if (hostage_object_is_valid( Cur_object_index ) )	{
		CurrentHostageIndex	= Objects[Cur_object_index].id;
	} else {
		Int3();		// Get John! (Object should be valid)
		i=hostage_object_is_valid( Cur_object_index );	// For debugging only
	}

	return 0;
}
Пример #3
0
static int PlaceHostage()	{
	int ctype,i;
	//update_due_to_new_segment();
	const auto cur_object_loc = compute_segment_center(Cursegp);

	ctype = -1;
	for (i=0; i<Num_total_object_types; i++ )	{
		if (ObjType[i] == OL_HOSTAGE )	{
			ctype = i;	
			break;
		}
	}

	Assert( ctype != -1 );

	if (place_object(Cursegp, cur_object_loc, ctype, 0 )==0)	{
		Int3();		// Debug below
		i=place_object(Cursegp, cur_object_loc, ctype, 0 );
		return 1;
	}

	const auto &&objp = vobjptridx(Cur_object_index);
	if (hostage_object_is_valid(objp))
	{
		CurrentHostageIndex	= get_hostage_id(objp);
	} else {
		Int3();		// Get John! (Object should be valid)
		hostage_object_is_valid(objp);	// For debugging only
	}

	return 0;
}
Пример #4
0
/*
 *  Place the ball & chain under the hero.  Make sure that the ball & chain
 *  variables are set (actually only needed when blind, but what the heck).
 *  It is assumed that when this is called, the ball and chain are NOT
 *  attached to the object list.
 *
 *  Should not be called while swallowed.
 */
void
placebc()
{
    if (!uchain || !uball) {
	impossible("Where are your ball and chain?");
	return;
    }

    (void) flooreffects(uchain, u.ux, u.uy, "");	/* chain might rust */

    if (carried(uball))		/* the ball is carried */
	u.bc_order = BCPOS_DIFFER;
    else {
	/* ball might rust -- already checked when carried */
	(void) flooreffects(uball, u.ux, u.uy, "");
	place_object(uball, u.ux, u.uy);
	u.bc_order = BCPOS_CHAIN;
    }

    place_object(uchain, u.ux, u.uy);

    u.bglyph = u.cglyph = levl[u.ux][u.uy].glyph;   /* pick up glyph */

    newsym(u.ux,u.uy);
}
Пример #5
0
//	------------------------------------------------------------------------------------------------------
//	Place current object at center of current segment.
int ObjectPlaceObject(void)
{
	int	old_cur_object_index;
	int	rval;
	if (Cur_object_type == OBJ_PLAYER)
	{
		int num_players = compute_num_players();
		Assert(num_players <= MAX_MULTI_PLAYERS);
		if (num_players > MAX_PLAYERS)
			editor_status("You just placed a cooperative player object");
		if (num_players == MAX_MULTI_PLAYERS) {
			editor_status_fmt("Can't place player object.  Already %i players.", MAX_MULTI_PLAYERS);
			return -1;
		}
	}

	//update_due_to_new_segment();
	const auto cur_object_loc = compute_segment_center(Cursegp);

	old_cur_object_index = Cur_object_index;
	rval = place_object(Cursegp, cur_object_loc, Cur_object_type, Cur_object_id);

	if (old_cur_object_index != Cur_object_index)
		vobjptr(Cur_object_index)->rtype.pobj_info.tmap_override = -1;

	return rval;

}
Пример #6
0
/* Routine when dying or quitting with a vault guard around */
void paygd(void) {
    struct monst *grd = findgd();
    struct obj *gold;
    int gx, gy;
    char buf[BUFSZ];

    if (!u.ugold || !grd)
        return;

    if (u.uinvault) {
        Your("%ld %s goes into the Magic Memory Vault.", u.ugold, currency(u.ugold));
        gx = u.ux;
        gy = u.uy;
    } else {
        if (grd->mpeaceful) { /* guard has no "right" to your gold */
            mongone(grd);
            return;
        }
        mnexto(grd);
        char name[BUFSZ];
        Monnam(name, BUFSZ, grd);
        pline("%s remits your gold to the vault.", name);
        gx = rooms[EGD(grd)->vroom].lx + rn2(2);
        gy = rooms[EGD(grd)->vroom].ly + rn2(2);
        sprintf(buf, "To Croesus: here's the gold recovered from %s the %s.", plname, mons[u.umonster].mname);
        make_grave(gx, gy, buf);
    }
    place_object(gold = mkgoldobj(u.ugold), gx, gy);
    stackobj(gold);
    mongone(grd);
}
Пример #7
0
/* 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);
    }
}
Пример #8
0
/* 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
0
/**
 * Create up to 'num' objects near the given coordinates in a vault.
 * \param c the current chunk
 * \param y co-ordinates
 * \param x co-ordinates
 * \param depth geneeration depth
 * \param num number of objects
 */
void vault_objects(struct chunk *c, int y, int x, int depth, int num)
{
    int i, j, k;

    /* Attempt to place 'num' objects */
    for (; num > 0; --num) {
		/* Try up to 11 spots looking for empty space */
		for (i = 0; i < 11; ++i) {
			/* Pick a random location */
			find_nearby_grid(c, &j, y, 2, &k, x, 3);

			/* Require "clean" floor space */
			if (!square_canputitem(c, j, k)) continue;

			/* Place an item or gold */
			if (randint0(100) < 75)
				place_object(c, j, k, depth, false, false, ORIGIN_SPECIAL, 0);
			else
				place_gold(c, j, k, depth, ORIGIN_VAULT);

			/* Placement accomplished */
			break;
		}
    }
}
Пример #10
0
void tea_pot_pursuit(int i)
{
    /* logic to move and place teapot */
    /* pursuit = 0:  prelim circling
     * pursuit = 1:  chasing renny  (backing up id renny is crashing)
     * pusuit = 2:  rotating slowly in the last place it was when renny left quad
     *
     * (they spin faster in celebration when renny is crashing)
     */
    if (full_objects[i].pursuit == 0)
    {
        full_objects[i].rot[0]-=30*(t_now-t_last);
        if (full_objects[i].rot[0]>360) full_objects[i].rot[0] -=360;
        full_objects[i].pos[0]=.45*quad_dims[0]*Cos(full_objects[i].rot[0]-90)+
                quads[full_objects[i].quad[0]][full_objects[i].quad[1]].center[0];
        full_objects[i].pos[2]=.45*quad_dims[0]*Sin(full_objects[i].rot[0]-90)+
                quads[full_objects[i].quad[0]][full_objects[i].quad[1]].center[1];
        full_objects[i].area[0]=(int)(full_objects[i].pos[0]+ x_offset)/X_DIM;
        full_objects[i].area[1]=(int)(full_objects[i].pos[2]+ z_offset)/Z_DIM;
        place_object(i);
    }
    else if (full_objects[i].pursuit == 2)
    {
        full_objects[i].rot[0]+=30*(t_now-t_last);
        if (full_objects[i].rot[0]>360) full_objects[i].rot[0] -=360;

    }

}
Пример #11
0
struct obj *mkobj_at(char let, struct level *lev, int x, int y, boolean artif)
{
	struct obj *otmp;

	otmp = mkobj(lev, let, artif);
	place_object(otmp, lev, x, y);
	return otmp;
}
Пример #12
0
struct obj *
mkobj_at(char let, int x, int y, boolean artif)
{
    struct obj *otmp;

    otmp = mkobj(let, artif);
    place_object(otmp, x, y);
    return(otmp);
}
Пример #13
0
struct obj *mksobj_at(int otyp, struct level *lev, int x, int y,
		      boolean init, boolean artif)
{
	struct obj *otmp;

	otmp = mksobj(lev, otyp, init, artif);
	place_object(otmp, lev, x, y);
	return otmp;
}
Пример #14
0
struct obj *
mksobj_at(int otyp, int x, int y, boolean init, boolean artif)
{
    struct obj *otmp;

    otmp = mksobj(otyp, init, artif);
    place_object(otmp, x, y);
    return(otmp);
}
Пример #15
0
/**
 * Perform the basic "tunnel" command
 *
 * Assumes that no monster is blocking the destination.
 * Uses twall() (above) to do all "terrain feature changing".
 * Returns true if repeated commands may continue.
 */
static bool do_cmd_tunnel_aux(int y, int x)
{
	bool more = false;
	int digging_chances[DIGGING_MAX];
	bool okay = false;
	bool gold = square_hasgoldvein(cave, y, x);
	bool rubble = square_isrubble(cave, y, x);

	/* Verify legality */
	if (!do_cmd_tunnel_test(y, x)) return (false);

	calc_digging_chances(&player->state, digging_chances);

	/* Do we succeed? */
	okay = (digging_chances[square_digging(cave, y, x) - 1] > randint0(1600));

	/* Success */
	if (okay && twall(y, x)) {
		/* Rubble is a special case - could be handled more generally NRM */
		if (rubble) {
			/* Message */
			msg("You have removed the rubble.");

			/* Place an object (except in town) */
			if ((randint0(100) < 10) && player->depth) {
				/* Create a simple object */
				place_object(cave, y, x, player->depth, false, false,
							 ORIGIN_RUBBLE, 0);

				/* Observe the new object */
				if (!ignore_item_ok(square_object(cave, y, x)) &&
					square_isseen(cave, y, x))
					msg("You have found something!");
			} 
		} else if (gold) {
			/* Found treasure */
			place_gold(cave, y, x, player->depth, ORIGIN_FLOOR);
			msg("You have found something!");
		} else {
			msg("You have finished the tunnel.");
		}
	} else {
		/* Failure, continue digging */
		if (rubble)
			msg("You dig in the rubble.");
		else
			msg("You tunnel into the %s.",
				square_apparent_name(cave, player, y, x));
		more = true;
		if (square_issecretdoor(cave, y, x))
			/* Occasional Search XXX XXX */
			if (randint0(100) < 25) search(false);
	}

	/* Result */
	return (more);
}
Пример #16
0
/*
 * Create up to "num" objects near the given coordinates
 * Only really called by some of the "vault" routines.
 */
void vault_objects(int y, int x, int num)
{
    int dummy = 0;
    int i = 0, j = y, k = x;

    cave_type *c_ptr;


    /* Attempt to place 'num' objects */
    for (; num > 0; --num)
    {
        /* Try up to 11 spots looking for empty space */
        for (i = 0; i < 11; ++i)
        {
            /* Pick a random location */
            while (dummy < SAFE_MAX_ATTEMPTS)
            {
                j = rand_spread(y, 2);
                k = rand_spread(x, 3);
                dummy++;
                if (!in_bounds(j, k)) continue;
                break;
            }


            if (dummy >= SAFE_MAX_ATTEMPTS)
            {
                if (cheat_room)
                {
                    msg_print("Warning! Could not place vault object!");

                }
            }


            /* Require "clean" floor space */
            c_ptr = &cave[j][k];
            if (!is_floor_grid(c_ptr) || c_ptr->o_idx) continue;

            /* Place an item */
            if (randint0(100) < 75)
            {
                place_object(j, k, 0L);
            }

            /* Place gold */
            else
            {
                place_gold(j, k);
            }

            /* Placement accomplished */
            break;
        }
    }
}
Пример #17
0
static void move_gold(struct obj *gold, int vroom) {
    signed char nx, ny;

    remove_object(gold);
    newsym(gold->ox, gold->oy);
    nx = rooms[vroom].lx + rn2(2);
    ny = rooms[vroom].ly + rn2(2);
    place_object(gold, nx, ny);
    stackobj(gold);
    newsym(nx, ny);
}
Пример #18
0
/* remove an item of armor and then drop it */
static void m_lose_armor(struct monst *mon, struct obj *obj)
{
	mon->misc_worn_check &= ~obj->owornmask;
	if (obj->owornmask)
	    update_mon_intrinsics(mon, obj, FALSE, FALSE);
	obj->owornmask = 0L;

	obj_extract_self(obj);
	place_object(obj, level, mon->mx, mon->my);
	/* call stackobj() if we ever drop anything that can merge */
	newsym(mon->mx, mon->my);
}
Пример #19
0
void render_objectMatrix () {	
	int i;
	tParticle *myParticle;
	
	local = (objectMatrix_section *) mySection->vars;
	
	// Insert the default section values into the size equation
	insertSectionVariables(&local->myParticleSystem->Evaluator);
	insertSectionVariables(&local->myParticleSystem->rate);
		
	particles_generate(local->myParticleSystem);
	particles_update  (local->myParticleSystem);

	if (local->myParticleSystem->particlesCount <= 0) return;
	
	if (local->myParticleSystem->disableDepthTest > 0) glDisable(GL_DEPTH_TEST);

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	
		// place the sources
		place_object (&local->myParticleSystem->Sources);
		
		// Render the objects instead of the particle system's particles
		myParticle = local->myParticleSystem->firstParticle;
	
		for (i = 0; i < local->myParticleSystem->particlesCount; i++) {
			if (myParticle->life <= 0.0f) // skip dead particles
				continue;
		
			// glColor4d(myParticle->red, myParticle->green, myParticle->blue, myParticle->alpha);
				
			glPushMatrix();

				glTranslated (myParticle->position.x, myParticle->position.y, myParticle->position.z);
				glRotated    (myParticle->rotation.x, 1, 0, 0);
				glRotated    (myParticle->rotation.y, 0, 1, 0);
				glRotated    (myParticle->rotation.z, 0, 0, 1);
				glScaled     (myParticle->size*myParticle->scale.x, myParticle->size*myParticle->scale.y, myParticle->size*myParticle->scale.z);	
			
				render_objectLayers (local->obj_part, local->layers, local->myParticleSystem->disableDepthTest);
			
			glPopMatrix();
			
		myParticle = myParticle->nextParticle;
	}
		
	if (local->myParticleSystem->disableDepthTest == 1)
		glEnable(GL_DEPTH_TEST);
			
	glPopMatrix();
}
Пример #20
0
static int PlaceHostage()	{
	int ctype,i;
	//update_due_to_new_segment();
	auto &Vertices = LevelSharedVertexState.get_vertices();
	auto &vcvertptr = Vertices.vcptr;
	const auto cur_object_loc = compute_segment_center(vcvertptr, Cursegp);

	ctype = -1;
	for (i=0; i<Num_total_object_types; i++ )	{
		if (ObjType[i] == OL_HOSTAGE )	{
			ctype = i;	
			break;
		}
	}

	Assert( ctype != -1 );

	if (place_object(Cursegp, cur_object_loc, ctype, 0 )==0)	{
		Int3();		// Debug below
		i=place_object(Cursegp, cur_object_loc, ctype, 0 );
		return 1;
	}
	return 0;
}
Пример #21
0
//	------------------------------------------------------------------------------------------------------
//	Place current object at center of current segment.
int ObjectPlaceObjectTmap(void)
{
	int	rval, old_cur_object_index;
	//update_due_to_new_segment();
	const auto cur_object_loc = compute_segment_center(Cursegp);

	old_cur_object_index = Cur_object_index;
	rval = place_object(Cursegp, cur_object_loc, Cur_object_type, Cur_object_id);

	if ((Cur_object_index != old_cur_object_index) && (Objects[Cur_object_index].render_type == RT_POLYOBJ))
		Objects[Cur_object_index].rtype.pobj_info.tmap_override = CurrentTexture;
	else
		editor_status("Unable to apply current texture map to this object.");
	
	return rval;
}
Пример #22
0
void render_objectShader () {	
	local = (objectShader_section *) mySection->vars;

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

		if (local->sources == NULL) {
			place_object (&local->evalPositioning);
			render_objectLayers (local->object, local->layers, local->enableDepthBufferClearing);			
		} else {
			deprecated_place_object (local->evalSources);
			objects_render();			
		}
		
	glPopMatrix();
}
Пример #23
0
void rloco(struct obj *obj)
{
	xchar tx, ty, otx, oty;
	boolean restricted_fall;
	int try_limit = 4000;

	if (obj->otyp == CORPSE && is_rider(&mons[obj->corpsenm])) {
	    if (revive_corpse(obj)) return;
	}

	obj_extract_self(obj);
	otx = obj->ox;
	oty = obj->oy;
	restricted_fall = (otx == 0 && level->dndest.lx);
	do {
	    tx = rn1(COLNO-3,2);
	    ty = rn2(ROWNO);
	    if (!--try_limit) break;
	} while (!goodpos(level, tx, ty, NULL, 0) ||
		/* bug: this lacks provision for handling the Wizard's tower */
		 (restricted_fall &&
		  (!within_bounded_area(tx, ty, level->dndest.lx, level->dndest.ly,
						level->dndest.hx, level->dndest.hy) ||
		   (level->dndest.nlx &&
		    within_bounded_area(tx, ty, level->dndest.nlx, level->dndest.nly,
						level->dndest.nhx, level->dndest.nhy)))));

	if (flooreffects(obj, tx, ty, "fall")) {
	    return;
	} else if (otx == 0 && oty == 0) {
	    ;	/* fell through a trap door; no update of old loc needed */
	} else {
	    if (costly_spot(otx, oty)
	      && (!costly_spot(tx, ty) ||
		  !strchr(in_rooms(level, tx, ty, 0), *in_rooms(level, otx, oty, 0)))) {
		if (costly_spot(u.ux, u.uy) &&
			    strchr(u.urooms, *in_rooms(level, otx, oty, 0)))
		    addtobill(obj, FALSE, FALSE, FALSE);
		else stolen_value(obj, otx, oty, FALSE, FALSE);
	    }
	    newsym(otx, oty);	/* update old location */
	}
	place_object(obj, level, tx, ty);
	newsym(tx, ty);
}
Пример #24
0
//	------------------------------------------------------------------------------------------------------
//	Place current object at center of current segment.
int ObjectPlaceObject(void)
{
	int	old_cur_object_index;
	int	rval;

	vms_vector	cur_object_loc;

#ifdef SHAREWARE
	if (ObjType[Cur_robot_type] == OL_PLAYER) {
		int num_players = compute_num_players();
		Assert(num_players <= MAX_PLAYERS);
		if (num_players == MAX_PLAYERS) {
			editor_status("Can't place player object.  Already %i players.", MAX_PLAYERS);
			return -1;
		}
	}
#endif

#ifndef SHAREWARE
	if (ObjType[Cur_robot_type] == OL_PLAYER) {
		int num_players = compute_num_players();
		Assert(num_players <= MAX_MULTI_PLAYERS);
		if (num_players > MAX_PLAYERS)
			editor_status("You just placed a cooperative player object");
		if (num_players == MAX_MULTI_PLAYERS) {
			editor_status("Can't place player object.  Already %i players.", MAX_MULTI_PLAYERS);
			return -1;
		}
	}
#endif

	//update_due_to_new_segment();
	compute_segment_center(&cur_object_loc, Cursegp);

	old_cur_object_index = Cur_object_index;
	rval = place_object(Cursegp, &cur_object_loc, Cur_robot_type);

	if (old_cur_object_index != Cur_object_index)
		Objects[Cur_object_index].rtype.pobj_info.tmap_override = -1;

	return rval;

}
Пример #25
0
/* Routine when dying or quitting with a vault guard around */
void
paygd(void)
{
    struct monst *grd = findgd();
    long umoney = money_cnt(invent);
    struct obj *coins, *nextcoins;
    int gx, gy;

    if (!umoney || !grd)
        return;

    if (u.uinvault) {
        pline("Your %ld %s goes into the Magic Memory Vault.", umoney,
              currency(umoney));
        gx = u.ux;
        gy = u.uy;
    } else {
        if (grd->mpeaceful) {   /* guard has no "right" to your gold */
            mongone(grd);
            return;
        }
        mnexto(grd);
        pline("%s remits your gold to the vault.", Monnam(grd));
        gx = level->rooms[EGD(grd)->vroom].lx + rn2(2);
        gy = level->rooms[EGD(grd)->vroom].ly + rn2(2);
        make_grave(level, gx, gy,
                   msgprintf(
                       "To Croesus: here's the gold recovered from %s the %s.",
                       u.uplname, mons[u.umonster].mname));
    }
    
    for (coins = invent; coins; coins = nextcoins) {
        nextcoins = coins->nobj;
        if (objects[coins->otyp].oc_class == COIN_CLASS) {
            unwield_silently(coins);
            freeinv(coins);
            place_object(coins, level, gx, gy);
            stackobj(coins);
        }
    }
    mongone(grd);
}
Пример #26
0
/* Be sure this corresponds with what happens to player-thrown objects in
 * dothrow.c (for consistency). --KAA
 * Returns 0 if object still exists (not destroyed).
 */
static int
drop_throw(struct obj *obj, boolean ohit, int x, int y)
{
    int retvalu = 1;
    int create;
    struct monst *mtmp;
    struct trap *t;

    if (breaks(obj, x, y))
        return 1;

    if (ohit && (is_multigen(obj) || obj->otyp == ROCK))
        create = !rn2(3);
    else
        create = 1;

    if (create &&
        !((mtmp = m_at(level, x, y)) && (mtmp->mtrapped) &&
          (t = t_at(level, x, y)) && (is_pit_trap(t->ttyp)))) {
        int objgone = 0;

        if (down_gate(x, y) != -1)
            objgone = ship_object(obj, x, y, FALSE);
        if (!objgone) {
            if (!flooreffects(obj, x, y, "fall")) {
                /* don't double-dip on damage */
                place_object(obj, level, x, y);
                if (!mtmp && x == u.ux && y == u.uy)
                    mtmp = &youmonst;
                if (mtmp && ohit)
                    passive_obj(mtmp, obj, NULL);
                stackobj(obj);
                retvalu = 0;
            }
        }
    } else
        obfree(obj, NULL);
    return retvalu;
}
Пример #27
0
/*
 *  set_bc()
 *
 *  The hero is either about to go blind or already blind and just punished.
 *  Set up the ball and chain variables so that the ball and chain are "felt".
 */
void
set_bc(int already_blind)
{
    int ball_on_floor = !carried(uball);

    u.bc_order = bc_order();    /* get the order */
    u.bc_felt = ball_on_floor ? BC_BALL | BC_CHAIN : BC_CHAIN;  /* felt */

    if (already_blind || Engulfed) {
        u.cglyph = u.bglyph = level->locations[u.ux][u.uy].mem_obj;
        return;
    }

    /* 
     *  Since we can still see, remove the ball&chain and get the glyph that
     *  would be beneath them.  Then put the ball&chain back.  This is pretty
     *  disgusting, but it will work.
     */
    remove_object(uchain);
    if (ball_on_floor)
        remove_object(uball);

    newsym(uchain->ox, uchain->oy);
    u.cglyph = level->locations[uchain->ox][uchain->oy].mem_obj;

    if (u.bc_order == BCPOS_DIFFER) {   /* different locations */
        place_object(uchain, level, uchain->ox, uchain->oy);
        newsym(uchain->ox, uchain->oy);
        if (ball_on_floor) {
            newsym(uball->ox, uball->oy);       /* see under ball */
            u.bglyph = level->locations[uball->ox][uball->oy].mem_obj;
            place_object(uball, level, uball->ox, uball->oy);
            newsym(uball->ox, uball->oy);       /* restore ball */
        }
    } else {
        u.bglyph = u.cglyph;
        if (u.bc_order == BCPOS_CHAIN) {
            place_object(uball, level, uball->ox, uball->oy);
            place_object(uchain, level, uchain->ox, uchain->oy);
        } else {
            place_object(uchain, level, uchain->ox, uchain->oy);
            place_object(uball, level, uball->ox, uball->oy);
        }
        newsym(uball->ox, uball->oy);
    }
}
Пример #28
0
void populate_game()
{
    unsigned int iseed = (unsigned int)time(NULL);
    int i=0, j=0;
    int halfspan = NUM_X_QUADS/2;  // max is NUM_X_QUADS/2
    int i_begin = NUM_X_QUADS/2-halfspan, i_end = 1+halfspan+NUM_X_QUADS/2;
    int j_begin = NUM_Z_QUADS/2-halfspan, j_end = 1+halfspan+NUM_X_QUADS/2;

    /* set up quad data */
    generate_game_quads();

    /* generate most of object data */
    srand(iseed);
    for (i=i_begin; i<i_end; i++)
    {
        for (j=j_begin; j<j_end; j++)
        {
            unsigned int new_seed = (unsigned int)rand();
            populate_game_quad(i, j, new_seed);
        }
    }

    /* final elevation and roll/pitch data*/
    for (i=0; i<num_objects; i++)
    {
        if (full_objects[i].type==0)      /* evil teapot */
            tea_pot_pursuit(i);
        else if (full_objects[i].type==5) /* flying martini glass */
            martini_glass_fly(i);
        else                              /* all other non moving objects */
            place_object(i);
    }
#ifdef DEBUG_QUADS
    printf("num_objs = %d, num_cubes = %d, num_prizes = %d num_trees = %d\n", num_objects, num_cubes, num_prizes, num_trees);
#endif
}
Пример #29
0
void
rloco(struct obj *obj)
{
    int tx, ty, otx, oty;

    otx = obj->ox;
    oty = obj->oy;

    if (obj->otyp == CORPSE && is_rider(&mons[obj->corpsenm])) {
        if (revive_corpse(obj))
            return;
    }

    obj_extract_self(obj);
    rloco_pos(level, obj, &tx, &ty);

    if (flooreffects(obj, tx, ty, "fall")) {
        return;
    } else if (otx == 0 && oty == 0) {
        ;       /* fell through a trap door; no update of old loc needed */
    } else {
        if (costly_spot(otx, oty)
            && (!costly_spot(tx, ty) ||
                !strchr(in_rooms(level, tx, ty, 0),
                        *in_rooms(level, otx, oty, 0)))) {
            if (costly_spot(u.ux, u.uy) &&
                strchr(u.urooms, *in_rooms(level, otx, oty, 0)))
                addtobill(obj, FALSE, FALSE, FALSE);
            else
                stolen_value(obj, otx, oty, FALSE, FALSE);
        }
        newsym(otx, oty);       /* update old location */
    }
    place_object(obj, level, tx, ty);
    newsym(tx, ty);
}
Пример #30
0
/*
 * Allocates some objects (using "place" and "type")
 */
static void alloc_object(int set, int typ, int num)
{
	int y, x, k;
	int dummy = 0;
	cave_type *c_ptr = NULL;

	/* Place some objects */
	for (k = 0; k < num; k++)
	{
		/* Pick a "legal" spot */
		while (dummy < SAFE_MAX_ATTEMPTS)
		{
			bool room;

			dummy++;

			/* Location */
			y = rand_range(min_hgt + 1, max_hgt - 2);
			x = rand_range(min_wid + 1, max_wid - 2);

			c_ptr = &cave[y][x];

			/* Require "naked" floor grid */
			if (!cave_naked_grid(c_ptr)) continue;

			/* Check for "room" */
			room = (c_ptr->info & CAVE_ROOM) ? TRUE : FALSE;

			/* Require corridor? */
			if ((set == ALLOC_SET_CORR) && room) continue;

			/* Require room? */
			if ((set == ALLOC_SET_ROOM) && !room) continue;

			/* Traps cannot be placed on 'icky' grids (rivers/lakes) */
			if ((typ == ALLOC_TYP_TRAP) && (c_ptr->info & CAVE_ICKY)) continue;

			/* Accept it */
			break;
		}

		if (dummy >= SAFE_MAX_ATTEMPTS)
		{
			if (cheat_room)
			{
				msg_print("Warning! Could not place object!");
			}
			return;
		}


		/* Place something */
		switch (typ)
		{
			case ALLOC_TYP_RUBBLE:
			{
				c_ptr->feat = FEAT_RUBBLE;
				break;
			}

			case ALLOC_TYP_TRAP:
			{
				place_trap(y, x);
				break;
			}

			case ALLOC_TYP_GOLD:
			{
				place_gold(y, x);
				break;
			}

			case ALLOC_TYP_OBJECT:
			{
				place_object(y, x, FALSE, FALSE);
				break;
			}

			case ALLOC_TYP_INVIS:
			{
				/* Create invisible wall */
				cave_set_feat(y, x, FEAT_FLOOR);
				(void)place_field(y, x, FT_WALL_INVIS);
				break;
			}
		}
	}
}