Ejemplo n.º 1
0
/**
 * Update the player's knowledge of the objects on a grid in the current level
 */
void square_know_pile(struct chunk *c, int y, int x)
{
	struct object *obj;

	if (c != cave) return;

	object_lists_check_integrity(c, player->cave);

	/* Know every item on this grid, greater knowledge for the player grid */
	for (obj = square_object(c, y, x); obj; obj = obj->next) {
		object_see(player, obj);
		if ((y == player->py) && (x == player->px)) {
			object_touch(player, obj);
		}
	}

	/* Remove known location of anything not on this grid */
	obj = square_object(player->cave, y, x);
	while (obj) {
		struct object *next = obj->next;
		assert(c->objects[obj->oidx]);
		if (!square_holds_object(c, y, x, c->objects[obj->oidx])) {
			struct object *original = c->objects[obj->oidx];
			square_excise_object(player->cave, y, x, obj);
			obj->iy = 0;
			obj->ix = 0;

			/* Delete objects which no longer exist anywhere */
			if (obj->notice & OBJ_NOTICE_IMAGINED) {
				delist_object(player->cave, obj);
				object_delete(&obj);
				original->known = NULL;
				delist_object(c, original);
				object_delete(&original);
			}
		}
		obj = next;
	}
}
Ejemplo n.º 2
0
void run_object_single(obj_type *obj,int tick)
{
		// spawning
		
	if (obj->spawning) object_spawn(obj);
	
	memmove(&obj->last_pnt,&obj->pnt,sizeof(d3pnt));
	memmove(&obj->last_ang,&obj->ang,sizeof(d3ang));

		// item counts
		
	obj->count++;
	if (obj->item_count!=0) obj->item_count--;
	
		// turning and looking
		
	if (obj->player) {
		if (!obj->input_freeze) {
			object_player_turn(obj);
			object_player_look(obj);
		}
		else {
			if (!obj->suspend) {
				object_turn(obj);
			}
		}
		object_fs_effect_run(tick,obj);
	}
	else {
		if (!obj->suspend) {
			object_turn(obj);
		}
	}
	
	object_thrust(obj);

		// watches

	object_watch(obj);

		// health recover

	object_health_recover(obj);

		// movement
	
	if (!obj->suspend) {
		object_auto_walk(obj);
	
		object_fix_motion(obj);
		object_movement(obj,&obj->forward_move);
		object_movement(obj,&obj->side_move);
		object_simple_movement(obj,&obj->vert_move);
		
		object_gravity(obj);
		object_fix_force(obj);
		object_move(obj);
		
		object_fix_bump_smooth(obj);
		object_ducking(obj);

		object_touch(obj);
		object_liquid(tick,obj);

		object_crush(obj,FALSE);

		item_pickup_check(obj);
	}

		// auto-growing

	object_grow_run(obj);
	
		// animation events

	if (obj->player) {
		object_event_animations(obj);
	}
	
		// death check
		
	object_death(obj);
}