Beispiel #1
0
//returns the number of the next object in a segment, skipping the player
static objnum_t get_next_object(const vsegptr_t seg,objnum_t id)
{
	if (id == object_none)
		return get_first_object(seg);
	for (auto o = vobjptr(id);;)
	{
		id = o->next;
		if (id == object_none)
			return get_first_object(seg);
		o = vobjptr(id);
		if (o != ConsoleObject)
			return id;
	}
}
Beispiel #2
0
static int LocalObjectPlaceObject(void)
{
	int	rval;

	Cur_goody_count = 0;

	if (Cur_object_type != OBJ_ROBOT)
	{
		Cur_object_type = OBJ_ROBOT;
		Cur_object_id = 3;	// class 1 drone
		Num_object_subtypes = N_robot_types;
	}

	rval = ObjectPlaceObject();
	if (rval == -1)
		return -1;

	const auto &&objp = vobjptr(Cur_object_index);
	objp->contains_type = Cur_goody_type;
	objp->contains_id = Cur_goody_id;
	objp->contains_count = Cur_goody_count;

	set_view_target_from_segment(Cursegp);

	return rval;
}
Beispiel #3
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;

}
Beispiel #4
0
static int LocalObjectSelectPrevinMine(void)
{
	int	rval, first_obj;

	rval = ObjectSelectPrevInMine();

	first_obj = Cur_object_index;

	if (Cur_object_index != object_none) {
		while (!is_legal_type_for_this_window(Cur_object_index)) {
			ObjectSelectPrevInMine();
			if (first_obj == Cur_object_index)
				break;
		}

		const auto &&objp = vobjptr(Cur_object_index);
		Cur_goody_type = objp->contains_type;
		Cur_goody_id = objp->contains_id;
		if (objp->contains_count < 0)
			objp->contains_count = 0;
		Cur_goody_count = objp->contains_count;
	}

	if (Cur_object_index != first_obj)
		set_view_target_from_segment(Cursegp);

	return rval;
}
Beispiel #5
0
static int is_legal_type_for_this_window(const objidx_t objnum)
{
	if (objnum == object_none)
		return 1;
	else
		return is_legal_type(vobjptr(objnum)->type);
}
Beispiel #6
0
//-------------------------------------------------------------------------
// Called when user presses "Prev Type" button.  This only works for polygon
// objects and it just selects the prev polygon model for the current object.
//-------------------------------------------------------------------------
static int RobotPrevType()
{
	if (Cur_object_index != object_none )	{
		const auto &&obj = vobjptr(Cur_object_index);
		if (obj->type == OBJ_ROBOT)
		{
			if (obj->id == 0 ) 
				obj->id = N_robot_types-1;
			else
				obj->id--;

			//Set polygon-object-specific data
			obj->rtype.pobj_info.model_num = Robot_info[get_robot_id(obj)].model_num;
			obj->rtype.pobj_info.subobj_flags = 0;
			//set Physics info
			obj->mtype.phys_info.flags |= (PF_LEVELLING);
			obj->shields = Robot_info[get_robot_id(obj)].strength;
			call_init_ai_object(obj, ai_behavior::AIB_NORMAL);

			Cur_object_id = get_robot_id(obj);
		}
	}
	Update_flags |= UF_WORLD_CHANGED;
	return 1;
}
Beispiel #7
0
//returns the number of the first object in a segment, skipping the player
static objnum_t get_first_object(const vsegptr_t seg)
{
	const auto id = seg->objects;
	if (id == object_none)
		return object_none;
	const auto &&o = vobjptr(id);
	if (o == ConsoleObject)
		return o->next;
	return id;
}
Beispiel #8
0
int ObjectFlipObject()
{
	const auto m = &vobjptr(Cur_object_index)->orient;

	vm_vec_negate(m->uvec);
	vm_vec_negate(m->rvec);

	Update_flags |= UF_WORLD_CHANGED;

	return 1;
}
Beispiel #9
0
static void update_goody_info(void)
{
	if (Cur_object_index != object_none )	{
		const auto &&obj = vobjptr(Cur_object_index);
		if (obj->type == OBJ_ROBOT)
		{
			obj->contains_type = Cur_goody_type;
			obj->contains_id = Cur_goody_id;
			obj->contains_count = Cur_goody_count;
		}
	}
}
Beispiel #10
0
//	------------------------------------------------------------------------------------------------------
int	ObjectSetDefault(void)
{
	//update_due_to_new_segment();

	if (Cur_object_index == object_none) {
		editor_status("No current object, cannot move.");
		return 1;
	}

	const auto &&objp = vobjptr(Cur_object_index);
	compute_segment_center(objp->pos, vcsegptr(objp->segnum));

	Update_flags |= UF_WORLD_CHANGED;

	return 1;
}
Beispiel #11
0
int ObjectMakeCoop(void)
{
	Assert(Cur_object_index != object_none);
	Assert(Cur_object_index < MAX_OBJECTS);
//	Assert(Objects[Cur_object_index.type == OBJ_PLAYER);

	const auto &&objp = vobjptr(Cur_object_index);
	if (objp->type == OBJ_PLAYER)
	{
		objp->type = OBJ_COOP;
		editor_status("You just made a player object COOPERATIVE");
	} else
		editor_status("This is not a player object");

	return 1;
}
Beispiel #12
0
static void move_object_to_position(const vobjptridx_t objp, const vms_vector &newpos)
{
	if (get_seg_masks(newpos, vcsegptr(objp->segnum), objp->size).facemask == 0)
	{
		objp->pos = newpos;
	} else {
		if (verify_object_seg(objp, newpos)) {
			int		fate;
			object	temp_viewer_obj;
			fvi_query fq;
			fvi_info	hit_info;

			temp_viewer_obj = *Viewer;
			auto viewer_segnum = find_object_seg(vobjptr(Viewer));
			temp_viewer_obj.segnum = viewer_segnum;

			//	If the viewer is outside the mine, get him in the mine!
			if (viewer_segnum == segment_none) {
				editor_status("Unable to move object, viewer not in mine.  Aborting");
				return;
#if 0
				vms_vector	last_outside_pos;
				//	While outside mine, move towards object
				count = 0;
				while (viewer_segnum == segment_none) {
					vms_vector	temp_vec;

					last_outside_pos = temp_viewer_obj.pos;

					vm_vec_avg(&temp_vec, &temp_viewer_obj.pos, newpos);
					temp_viewer_obj.pos = temp_vec;
					viewer_segnum = find_object_seg(&temp_viewer_obj);
					temp_viewer_obj.segnum = viewer_segnum;

					if (count > 5) {
						editor_status("Unable to move object, can't get viewer in mine.  Aborting");
						return;
					}
				}

				count = 0;
				//	While inside mine, move away from object.
				while (viewer_segnum != segment_none) {

					vms_vector	temp_vec;

					vm_vec_avg(&temp_vec, &temp_viewer_obj.pos, &last_outside_pos);
					temp_viewer_obj.pos = temp_vec;
					update_object_seg(&temp_viewer_obj);
					viewer_segnum = find_object_seg(&temp_viewer_obj);
					temp_viewer_obj.segnum = viewer_segnum;

					if (count > 5) {
						editor_status("Unable to move object, can't get viewer back out of mine.  Aborting");
						return;
					}
				}
#endif
			}

			fq.p0						= &temp_viewer_obj.pos;
			fq.startseg				= temp_viewer_obj.segnum;
			fq.p1						= &newpos;
			fq.rad					= temp_viewer_obj.size;
			fq.thisobjnum			= object_none;
			fq.ignore_obj_list.first = nullptr;
			fq.flags					= 0;

			fate = find_vector_intersection(fq, hit_info);
			if (fate == HIT_WALL) {

				objp->pos = hit_info.hit_pnt;
				const auto &&segp = find_object_seg(objp);
				if (segp != segment_none)
					obj_relink(objp, segp);
			} else {
				editor_status("Attempted to move object out of mine.  Object not moved.");
			}
		}
	}

	Update_flags |= UF_WORLD_CHANGED;
}