Example #1
0
File: objects.c Project: rzel/dim3
int object_script_spawn(char *name,char *script,char *params,d3pnt *pnt,d3ang *ang,bool hide,char *err_str)
{
	int					idx;
	char				obj_err_str[256];
	spot_type			spot;
	obj_type			*obj;
	
		// create fake spot

	bzero(&spot,sizeof(spot_type));

	strcpy(spot.name,name);
	strcpy(spot.script,script);
	strcpy(spot.params,params);

	memmove(&spot.pnt,pnt,sizeof(d3pnt));
	memmove(&spot.ang,ang,sizeof(d3ang));

		// start object

	idx=object_start(&spot,name,object_type_object,bt_map,obj_err_str);
	if (idx==-1) {
		sprintf(err_str,"Object Spawn Failed: %s",obj_err_str);
		console_add_error(err_str);
		
		return(-1);
	}
	
	obj=server.obj_list.objs[idx];

	obj->script_spawned=TRUE;

		// hide object

	if (hide) {
		obj->hidden=TRUE;
		obj->contact.object_on=FALSE;
		obj->contact.projectile_on=FALSE;
		obj->contact.force_on=FALSE;
	}
	
		// force a spawn call
		
	if (!object_spawn(obj,obj_err_str)) {
		sprintf(err_str,"Object Spawn Failed: %s",obj_err_str);
		console_add_error(err_str);
		
		object_dispose_single(idx);
		return(-1);
	}

		// return index

	return(idx);
}
Example #2
0
File: game.c Project: prophile/dim3
void game_reset_single_object(obj_type *obj,bool reposition)
{
	spot_type		*spot;

	obj->score.kill=obj->score.death=obj->score.suicide=obj->score.goal=obj->score.score=0;
	obj->spawning=TRUE;
	
	obj->input_freeze=FALSE;
	obj->death_trigger=FALSE;
	
	object_stop(obj);
	
	if (reposition) {
		spot=script_find_network_spot(obj);
		if (spot!=NULL) object_set_position(obj,spot->pnt.x,spot->pnt.y,spot->pnt.z,spot->ang.y,0);
	}
	
	object_spawn(obj);
}
Example #3
0
int world_load(const char *fname) {
	int i;
	const char *hint;
	if (world.map)
		world_unload();
	if (!(world.map = d_map_load(fname)))
		return 0;
	world.submap = 0;

	for (i = 0; i < world.map->objects; i++) {
		object_spawn(i, world_object_prop(i, "NAME"));
	}

	if (d_platform_get().platform & DARNIT_PLATFORM_PANDORA)
		hint = d_map_prop(world.map->prop, "hint_pandora");
	else
		hint = d_map_prop(world.map->prop, "hint");
	if (!strcmp(hint, "NO SUCH KEY"))
		hint = "";
	camera_set_hint(hint);

	return 1;
}
Example #4
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);
}
Example #5
0
bool server_game_start(char *game_script_name,int skill,network_reply_join_remotes *remotes,char *err_str)
{
	int							n;
	network_request_object_add	*obj_add;
	
		// initialize lists
		
	model_initialize();
		
	object_initialize_list();
	weapon_initialize_list();
	proj_setup_initialize_list();
	
	scripts_initialize();
	script_globals_initialize();
	timers_initialize();

		// setup skill level

	server.skill=skill;
	
		// run game script

	map.info.name[0]=0x0;
	map.info.player_start_name[0]=0x0;
	map.info.player_start_type[0]=0x0;
	map.info.in_load=FALSE;
	
	server.player_obj_uid=-1;
	
	js.game_attach.thing_type=thing_type_game;
	js.game_attach.thing_uid=-1;

	scripts_clear_attach_data(&js.game_attach);
	
	if (!scripts_add(&js.game_attach,"Game",game_script_name,NULL,err_str)) return(FALSE);
	
		// editor map override?
		
	if (setup.editor_override.on) {
		strcpy(map.info.name,setup.editor_override.map);
	}
	
		// can't start a game without a map
	
	if (map.info.name[0]==0x0) {
		strcpy(err_str,"Game: No start map specified in game script");
		return(FALSE);
	}

		// prepare for any script based spawns

	object_script_spawn_start();
	
		// put in additional objects (remotes, bots)
		
	if (remotes!=NULL) {
	
		obj_add=remotes->objects;
		
		for (n=0;n!=remotes->count;n++) {
			remote_add(obj_add,FALSE);
			obj_add++;
		}
	}
	
		// start player object
	
	server.player_obj_uid=object_start(NULL,TRUE,bt_game,-1,err_str);
	if (server.player_obj_uid==-1) {
		scripts_dispose(js.game_attach.script_uid);
		return(FALSE);
	}
			
		// force player to auto-spawn
		// spawing of player needs to happen before map_start events
		
	object_spawn(object_find_uid(server.player_obj_uid));

		// finish any script based spawns

	object_script_spawn_finish();
	
	return(TRUE);
}