[Add] planet_getClass. Lots more music.

This commit is contained in:
Allanis 2013-08-24 11:32:13 +01:00
parent 0b9f89e4a9
commit e3ddc663bf
15 changed files with 146 additions and 42 deletions

View File

@ -14,15 +14,34 @@ function choose(str)
music.play() music.play()
elseif str == "land" then elseif str == "land" then
music.load("agriculture") planet = space.landName()
class = space.planetClass(planet)
if class == "M" then
mus = "agriculture"
elseif class == "" then
mus = "ocean"
elseif class == "" then
mus = "snow"
else
if space.planetServices(planet) > 0 then
mus = "cosmostation"
else
mus = "agriculture"
end
end
music.load(mus)
music.play() music.play()
elseif str == "takeoff" then elseif str == "takeoff" then
music.load("liftoff") takeoff = { "liftoff", "launch2", "launch3chatstart" }
music.load(takeoff[rnd.int(1, #takeoff)])
music.play() music.play()
elseif str == "ambient" then elseif str == "ambient" then
music.load("machina") ambient = { "peace1", "mission", "peace2", "peace4", "peace6" }
music.load(ambient[rnd.int(1, #ambient)])
music.play() music.play()
elseif str == "combat" then elseif str == "combat" then

BIN
snd/music/cosmostation.ogg Normal file

Binary file not shown.

BIN
snd/music/launch2.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
snd/music/mission.ogg Normal file

Binary file not shown.

BIN
snd/music/ocean.ogg Normal file

Binary file not shown.

BIN
snd/music/peace1.ogg Normal file

Binary file not shown.

BIN
snd/music/peace2.ogg Normal file

Binary file not shown.

BIN
snd/music/peace4.ogg Normal file

Binary file not shown.

BIN
snd/music/peace6.ogg Normal file

Binary file not shown.

BIN
snd/music/snow.ogg Normal file

Binary file not shown.

View File

@ -1025,9 +1025,6 @@ void land(Planet* p) {
if(landed) return; if(landed) return;
/* Change music. */
music_choose("land");
/* Load stuff. */ /* Load stuff. */
land_planet = p; land_planet = p;
gfx_exterior = gl_newImage(p->gfx_exterior); gfx_exterior = gl_newImage(p->gfx_exterior);
@ -1079,6 +1076,11 @@ void land(Planet* p) {
landed = 1; landed = 1;
/* Change the music. */
music_choose("land");
/* Run hooks. */
hooks_run("land"); hooks_run("land");
/* Generate mission computer stuff. */ /* Generate mission computer stuff. */

View File

@ -30,13 +30,17 @@ static int space_landName(lua_State* L);
static int space_systemName(lua_State* L); static int space_systemName(lua_State* L);
static int space_jumpDist(lua_State* L); static int space_jumpDist(lua_State* L);
static int space_faction(lua_State* L); static int space_faction(lua_State* L);
static int space_planetClass(lua_State* L);
static int space_planetServices(lua_State* L);
static const luaL_reg space_methods[] = { static const luaL_reg space_methods[] = {
{ "getPlanet", space_getPlanet }, { "getPlanet", space_getPlanet },
{ "getSystem", space_getSystem }, { "getSystem", space_getSystem },
{ "landName", space_landName }, { "landName", space_landName },
{ "system", space_systemName }, { "system", space_systemName },
{ "jumpDist", space_jumpDist }, { "jumpDist", space_jumpDist },
{ "spaceFaction", space_faction }, { "spaceFaction", space_faction },
{ "planetClass", space_planetClass },
{ "planetServices", space_planetServices },
{ 0, 0 } { 0, 0 }
}; };
@ -315,6 +319,44 @@ static int space_faction(lua_State* L) {
return 1; return 1;
} }
static int space_planetClass(lua_State* L) {
Planet* p;
char buf[2];
LLUA_MIN_ARGS(1);
/* Get planet. */
if(lua_isstring(L, 1))
p = planet_get((char*)lua_tostring(L,1));
else
LLUA_INVALID_PARAMETER();
if(p == NULL) return 0;
/* Return the class. */
buf[0] = planet_getClass(p);
buf[1] = '\0';
lua_pushstring(L, buf);
return 1;
}
static int space_planetServices(lua_State* L) {
Planet* p;
LLUA_MIN_ARGS(1);
/* Get planet. */
if(lua_isstring(L, 1))
p = planet_get((char*)lua_tostring(L,1));
else
LLUA_INVALID_PARAMETER();
if(p == NULL) return 0;
lua_pushnumber(L, p->services);
return 1;
}
/* -- Time. -- */ /* -- Time. -- */
static int time_get(lua_State* L) { static int time_get(lua_State* L) {
lua_pushnumber(L, ltime_get()); lua_pushnumber(L, ltime_get());

View File

@ -156,38 +156,78 @@ void planets_minimap(const double res, const double w,
/* Basically return a PlanetClass integer from a char. */ /* Basically return a PlanetClass integer from a char. */
static PlanetClass planetclass_get(const char a) { static PlanetClass planetclass_get(const char a) {
switch(a) { switch(a) {
/* Planets use letters. */ /* Planets use letters. */
case 'A': return PLANET_CLASS_A; case 'A': return PLANET_CLASS_A;
case 'B': return PLANET_CLASS_B; case 'B': return PLANET_CLASS_B;
case 'C': return PLANET_CLASS_C; case 'C': return PLANET_CLASS_C;
case 'D': return PLANET_CLASS_D; case 'D': return PLANET_CLASS_D;
case 'E': return PLANET_CLASS_E; case 'E': return PLANET_CLASS_E;
case 'F': return PLANET_CLASS_F; case 'F': return PLANET_CLASS_F;
case 'G': return PLANET_CLASS_G; case 'G': return PLANET_CLASS_G;
case 'H': return PLANET_CLASS_H; case 'H': return PLANET_CLASS_H;
case 'I': return PLANET_CLASS_I; case 'I': return PLANET_CLASS_I;
case 'J': return PLANET_CLASS_J; case 'J': return PLANET_CLASS_J;
case 'K': return PLANET_CLASS_K; case 'K': return PLANET_CLASS_K;
case 'L': return PLANET_CLASS_L; case 'L': return PLANET_CLASS_L;
case 'M': return PLANET_CLASS_M; case 'M': return PLANET_CLASS_M;
case 'N': return PLANET_CLASS_N; case 'N': return PLANET_CLASS_N;
case 'O': return PLANET_CLASS_O; case 'O': return PLANET_CLASS_O;
case 'P': return PLANET_CLASS_P; case 'P': return PLANET_CLASS_P;
case 'Q': return PLANET_CLASS_Q; case 'Q': return PLANET_CLASS_Q;
case 'R': return PLANET_CLASS_R; case 'R': return PLANET_CLASS_R;
case 'S': return PLANET_CLASS_S; case 'S': return PLANET_CLASS_S;
case 'T': return PLANET_CLASS_T; case 'T': return PLANET_CLASS_T;
case 'X': return PLANET_CLASS_X; case 'X': return PLANET_CLASS_X;
case 'Y': return PLANET_CLASS_Y; case 'Y': return PLANET_CLASS_Y;
case 'Z': return PLANET_CLASS_Z; case 'Z': return PLANET_CLASS_Z;
/* Stations use numbers as there isn't as many. */ /* Stations use numbers as there isn't as many. */
case '0' : return STATION_CLASS_A; case '0' : return STATION_CLASS_A;
case '1' : return STATION_CLASS_B; case '1' : return STATION_CLASS_B;
case '2' : return STATION_CLASS_C; case '2' : return STATION_CLASS_C;
case '3' : return STATION_CLASS_D; case '3' : return STATION_CLASS_D;
default: return PLANET_CLASS_NULL; default:
WARN("Invalid planet class.");
return PLANET_CLASS_NULL;
};
}
char planet_getClass(Planet* p) {
switch(p->class) {
case PLANET_CLASS_A: return 'A';
case PLANET_CLASS_B: return 'B';
case PLANET_CLASS_C: return 'C';
case PLANET_CLASS_D: return 'D';
case PLANET_CLASS_E: return 'E';
case PLANET_CLASS_F: return 'F';
case PLANET_CLASS_G: return 'G';
case PLANET_CLASS_H: return 'H';
case PLANET_CLASS_I: return 'I';
case PLANET_CLASS_J: return 'J';
case PLANET_CLASS_K: return 'K';
case PLANET_CLASS_L: return 'L';
case PLANET_CLASS_M: return 'M';
case PLANET_CLASS_N: return 'N';
case PLANET_CLASS_O: return 'O';
case PLANET_CLASS_P: return 'P';
case PLANET_CLASS_Q: return 'Q';
case PLANET_CLASS_R: return 'R';
case PLANET_CLASS_S: return 'S';
case PLANET_CLASS_T: return 'T';
case PLANET_CLASS_X: return 'X';
case PLANET_CLASS_Y: return 'Y';
case PLANET_CLASS_Z: return 'Z';
/* Stations. */
case STATION_CLASS_A: return '0';
case STATION_CLASS_B: return '1';
case STATION_CLASS_C: return '2';
case STATION_CLASS_D: return '3';
default:
WARN("Invalid planet class.");
return 0;
}; };
} }

View File

@ -118,6 +118,7 @@ void space_exit(void);
/* Planet stuff. */ /* Planet stuff. */
char* planet_getSystem(char* planetname); char* planet_getSystem(char* planetname);
Planet* planet_get(char* planetname); Planet* planet_get(char* planetname);
char planet_getClass(Planet* p);
/* Render. */ /* Render. */
void space_render(const double dt); void space_render(const double dt);