Пример #1
0
bool proj_setup_start_script(obj_type *obj,weapon_type *weap,proj_setup_type *proj_setup,bool no_construct,char *err_str)
{
		// create the script

	proj_setup->script_idx=scripts_add(thing_type_projectile,"Projectiles",proj_setup->name,obj->idx,weap->idx,proj_setup->idx,err_str);
	if (proj_setup->script_idx==-1) return(FALSE);
		
		// send the construct event
	
	if (no_construct) return(TRUE);

	return(scripts_post_event(proj_setup->script_idx,-1,sd_event_construct,0,0,err_str));
}
Пример #2
0
bool object_start_script(obj_type *obj,bool no_construct,char *err_str)
{
	char				script_name[file_str_len];

		// is it a non-script scenery?
		// this is usually something set when re-loading
		// state from a saved file

	if (obj->scenery.on) {
		obj->script_idx=-1;
		return(TRUE);
	}

		// if player, use player script
		// or overridden multiplayer script,
		// otherwise use script setup by spot
	
	script_name[0]=0x0;

	if (obj->type==object_type_player) {
		if (net_setup.mode!=net_mode_none) strcpy(script_name,iface.multiplayer.game_list.games[net_setup.game_idx].script.player_script);
		if (script_name[0]==0x0) strcpy(script_name,"Player");
	}
	else {
		strcpy(script_name,obj->spawn_spot.script);
	}
	
		// create the script

	obj->script_idx=scripts_add(thing_type_object,"Objects",script_name,obj->idx,-1,-1,err_str);
	if (obj->script_idx==-1) return(FALSE);
			
		// send the construct event
	
	if (no_construct) return(TRUE);

	return(scripts_post_event(obj->script_idx,-1,sd_event_construct,0,0,err_str));
}
Пример #3
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);
}