[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());
|
||||||
|
Loading…
Reference in New Issue
Block a user