[Add] Cargo missions take into account fright distance.
This commit is contained in:
parent
472579aa2a
commit
82ee8a41a7
@ -33,8 +33,8 @@ function create()
|
|||||||
if i > 10 then
|
if i > 10 then
|
||||||
misn.finish(false)
|
misn.finish(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
system = space.getSystem(planet)
|
system = space.getSystem(planet)
|
||||||
|
misn_dist = space.jumpDist(system)
|
||||||
|
|
||||||
-- Missions generic.
|
-- Missions generic.
|
||||||
misn_type = "Cargo"
|
misn_type = "Cargo"
|
||||||
@ -48,7 +48,9 @@ function create()
|
|||||||
elseif i == 1 then carg_type = "Ore"
|
elseif i == 1 then carg_type = "Ore"
|
||||||
end
|
end
|
||||||
misn.setDesc(string.format(misn_desc, planet, system, carg_mass, carg_type))
|
misn.setDesc(string.format(misn_desc, planet, system, carg_mass, carg_type))
|
||||||
reward = carg_mass * (750 + rnd.int(250)) + rnd.int(5000)
|
reward = misn_dist * carg_mass * (250+rnd.int(150)) +
|
||||||
|
carg_mass * (150+rnd.int(75)) +
|
||||||
|
rnd.int(1500)
|
||||||
misn.setReward(string.format(misn_reward, reward))
|
misn.setReward(string.format(misn_reward, reward))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ function create()
|
|||||||
misn.finish(false)
|
misn.finish(false)
|
||||||
end
|
end
|
||||||
system = space.getSystem(planet)
|
system = space.getSystem(planet)
|
||||||
|
misn_dist = space.jumpDist(system)
|
||||||
|
|
||||||
-- Mission generics.
|
-- Mission generics.
|
||||||
misn_type = "Cargo"
|
misn_type = "Cargo"
|
||||||
@ -47,7 +48,9 @@ function create()
|
|||||||
end
|
end
|
||||||
|
|
||||||
misn.setDesc(string.format(misn_desc, carg_mass, carg_type, planet, system))
|
misn.setDesc(string.format(misn_desc, carg_mass, carg_type, planet, system))
|
||||||
reward = carg_mass * (1250+rnd.int(250)) + rnd.int(7500)
|
reward = misn_dist * carg_mass * (500+rnd.int(250)) +
|
||||||
|
carg_mass * (250+rnd.int(150)) +
|
||||||
|
rnd.int(2500)
|
||||||
misn.setReward(string.format(misn_reward, reward))
|
misn.setReward(string.format(misn_reward, reward))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -91,10 +91,12 @@ static const luaL_reg var_methods[] = {
|
|||||||
static int space_getPlanet(lua_State* L);
|
static int space_getPlanet(lua_State* L);
|
||||||
static int space_getSystem(lua_State* L);
|
static int space_getSystem(lua_State* L);
|
||||||
static int space_landName(lua_State* L);
|
static int space_landName(lua_State* L);
|
||||||
|
static int space_jumpDist(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 },
|
||||||
|
{ "jumpDist", space_jumpDist },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -501,9 +503,8 @@ static int space_getPlanet(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int space_getSystem(lua_State* L) {
|
static int space_getSystem(lua_State* L) {
|
||||||
char* planetname, *system;
|
|
||||||
|
|
||||||
MIN_ARGS(1);
|
MIN_ARGS(1);
|
||||||
|
char* planetname, *system;
|
||||||
|
|
||||||
if(lua_isstring(L, -1)) planetname = (char*) lua_tostring(L, -1);
|
if(lua_isstring(L, -1)) planetname = (char*) lua_tostring(L, -1);
|
||||||
else return 0;
|
else return 0;
|
||||||
@ -521,6 +522,31 @@ static int space_landName(lua_State* L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int space_jumpDist(lua_State* L) {
|
||||||
|
MIN_ARGS(1);
|
||||||
|
StarSystem** s;
|
||||||
|
int jumps;
|
||||||
|
char* start, *goal;
|
||||||
|
|
||||||
|
if(lua_isstring(L, -1))
|
||||||
|
start = (char*)lua_tostring(L, -1);
|
||||||
|
else {
|
||||||
|
MISN_DEBUG("invalid parameter 1");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((lua_gettop(L) > 1) && lua_isstring(L, -2))
|
||||||
|
goal = (char*) lua_tostring(L, -2);
|
||||||
|
else
|
||||||
|
goal = cur_system->name;
|
||||||
|
|
||||||
|
s = system_getJumpPath(&jumps, start, goal);
|
||||||
|
free(s);
|
||||||
|
|
||||||
|
lua_pushnumber(L, jumps);
|
||||||
|
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());
|
||||||
|
22
src/space.h
22
src/space.h
@ -39,7 +39,7 @@ typedef enum PlanetClass_ {
|
|||||||
} PlanetClass;
|
} PlanetClass;
|
||||||
|
|
||||||
// Planet services.
|
// Planet services.
|
||||||
#define PLANET_SERVICE_LAND (1<<0) // Can we land?
|
#define PLANET_SERVICE_LAND (1<<0) // Can we land?
|
||||||
#define PLANET_SERVICE_BASIC (1<<1) // Refueling, spaceport bar, new.
|
#define PLANET_SERVICE_BASIC (1<<1) // Refueling, spaceport bar, new.
|
||||||
#define PLANET_SERVICE_COMMODITY (1<<2)
|
#define PLANET_SERVICE_COMMODITY (1<<2)
|
||||||
#define PLANET_SERVICE_OUTFITS (1<<3)
|
#define PLANET_SERVICE_OUTFITS (1<<3)
|
||||||
@ -47,24 +47,24 @@ typedef enum PlanetClass_ {
|
|||||||
#define planet_hasService(p,s) ((p)->services & s)
|
#define planet_hasService(p,s) ((p)->services & s)
|
||||||
|
|
||||||
typedef struct Planet_ {
|
typedef struct Planet_ {
|
||||||
char* name; // Planet name
|
char* name; // Planet name
|
||||||
Vec2 pos; // Position in star system.
|
Vec2 pos; // Position in star system.
|
||||||
|
|
||||||
PlanetClass class; // Planet type.
|
PlanetClass class; // Planet type.
|
||||||
int faction; // Planet faction.
|
int faction; // Planet faction.
|
||||||
|
|
||||||
char* description; // Planet description.
|
char* description; // Planet description.
|
||||||
char* bar_description; // Spaceport bar description.
|
char* bar_description; // Spaceport bar description.
|
||||||
unsigned int services; // Offered services.
|
unsigned int services; // Offered services.
|
||||||
Commodity** commodities; // Commodities sold.
|
Commodity** commodities; // Commodities sold.
|
||||||
int ncommodities; // Amount in stock.
|
int ncommodities; // Amount in stock.
|
||||||
|
|
||||||
// tech[0] stores global tech level (everything that and below) while
|
// tech[0] stores global tech level (everything that and below) while
|
||||||
// tech[1-PLANET_TECH_MAX] stores the unique tech levels.
|
// tech[1-PLANET_TECH_MAX] stores the unique tech levels.
|
||||||
int tech[PLANET_TECH_MAX];
|
int tech[PLANET_TECH_MAX];
|
||||||
|
|
||||||
glTexture* gfx_space; // Graphics in space.
|
glTexture* gfx_space; // Graphics in space.
|
||||||
glTexture* gfx_exterior; // Graphics in the exterior.
|
glTexture* gfx_exterior; // Graphics in the exterior.
|
||||||
} Planet;
|
} Planet;
|
||||||
|
|
||||||
// Star systems.
|
// Star systems.
|
||||||
|
Loading…
Reference in New Issue
Block a user