[Add] Merchant vessels are now able to go to hyperspace.
[Change] Overpowered merchant ship a little for testing purposes.
This commit is contained in:
parent
14735a362d
commit
34a6be43df
@ -25,7 +25,7 @@
|
||||
<cap_cargo>25</cap_cargo>
|
||||
</characteristics>
|
||||
<outfits>
|
||||
<outfit quantity='1'>Laser</outfit>
|
||||
<outfit quantity='3'>Laser</outfit>
|
||||
</outfits>
|
||||
</ship>
|
||||
<ship name = "Leapard">
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Start>
|
||||
<name>Dark Tides</name>
|
||||
<player>
|
||||
<ship>Lancer</ship>
|
||||
<ship>Merchant Ship</ship>
|
||||
<credits>
|
||||
<low>500</low>
|
||||
<high>1500</high>
|
||||
|
@ -3,7 +3,10 @@ control_rate = 2
|
||||
|
||||
-- Required "control" function.
|
||||
function control()
|
||||
if ai.taskname() == "none" then
|
||||
task = ai.taskname()
|
||||
if task == "hyperspace" then
|
||||
ai.hyperspace() -- Try to go to hyperspace.
|
||||
elseif task == "none" then
|
||||
planet = ai.rndplanet()
|
||||
ai.pushtask(0, "go", planet)
|
||||
end
|
||||
@ -62,7 +65,15 @@ end
|
||||
--Waits.
|
||||
function land()
|
||||
if ai.timeup(0) then
|
||||
ai.pushtask(0, "runaway", player)
|
||||
ai.pushtask(0, "hyperspace")
|
||||
end
|
||||
end
|
||||
|
||||
-- Go to hyperspace YEAAAHHH!!
|
||||
function hyperspace()
|
||||
dir = ai.face(-1) -- Face away from (0,0)
|
||||
if(dir < 10) then
|
||||
ai.accel()
|
||||
end
|
||||
end
|
||||
|
||||
|
23
src/ai.c
23
src/ai.c
@ -588,22 +588,25 @@ static int ai_face(lua_State* L) {
|
||||
MIN_ARGS(1);
|
||||
Vec2* v; // Grab the position to face.
|
||||
Pilot* p;
|
||||
double mod, diff;
|
||||
int invert = 0;
|
||||
int n = -2;
|
||||
|
||||
if(lua_isnumber(L,1)) {
|
||||
p = pilot_get((unsigned int)lua_tonumber(L,1));
|
||||
if(lua_isnumber(L, 1))
|
||||
n = (int)lua_tonumber(L, 1);
|
||||
|
||||
if(n >= 0) {
|
||||
p = pilot_get(n);
|
||||
if(p == NULL) return 0; // Make sure pilot is valid.
|
||||
v = &p->solid->pos;
|
||||
}
|
||||
else if(lua_islightuserdata(L,1)) v = (Vec2*)lua_topointer(L,1);
|
||||
|
||||
double mod = -10;
|
||||
if(lua_gettop(L) > 1 && lua_isnumber(L,2))
|
||||
switch((int)lua_tonumber(L,2)) {
|
||||
case 0: break;
|
||||
case 1: mod *= -1; break;
|
||||
case 2: break;
|
||||
}
|
||||
double diff = angle_diff(cur_pilot->solid->dir, vect_angle(&cur_pilot->solid->pos, v));
|
||||
mod = -10;
|
||||
if(lua_gettop(L) > 1 && lua_isnumber(L,2)) invert = (int)lua_tonumber(L,2);
|
||||
if(invert) mod *= -1;
|
||||
diff = angle_diff(cur_pilot->solid->dir,
|
||||
(n==-1) ? VANGLE(cur_pilot->solid->pos) : vect_angle(&cur_pilot->solid->pos, v));
|
||||
|
||||
pilot_turn = mod*diff;
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h> // We don't need this?
|
||||
|
||||
#include "lephisto.h"
|
||||
#include "log.h"
|
||||
@ -280,13 +279,13 @@ static void pilot_hyperspace(Pilot* p) {
|
||||
double diff;
|
||||
|
||||
if(VMOD(p->solid->vel) > MIN_VEL_ERR) {
|
||||
diff = pilot_face(p, VANGLE(player->solid->vel) + M_PI);
|
||||
diff = pilot_face(p, VANGLE(p->solid->vel) + M_PI);
|
||||
|
||||
if(ABS(diff) < MAX_DIR_ERR) // Brake.
|
||||
vect_pset(&p->solid->force, p->ship->thrust, p->solid->dir);
|
||||
} else {
|
||||
vectnull(&p->solid->force); // Stop accelerating.
|
||||
diff = pilot_face(p, VANGLE(player->solid->pos));
|
||||
diff = pilot_face(p, VANGLE(p->solid->pos));
|
||||
|
||||
if(ABS(diff) < MAX_DIR_ERR) {
|
||||
// We should prepare for the jump now.
|
||||
@ -419,6 +418,9 @@ void pilot_destroy(Pilot* p) {
|
||||
for(i = 0; i < pilots; i++)
|
||||
if(pilot_stack[i] == p)
|
||||
break;
|
||||
|
||||
pilots--;
|
||||
|
||||
while(i < pilots) {
|
||||
pilot_stack[i] = pilot_stack[i+1];
|
||||
i++;
|
||||
|
@ -250,9 +250,11 @@ void player_render(void) {
|
||||
glFont* f;
|
||||
|
||||
// Render the player target graphics.
|
||||
if(player_target != PLAYER_ID) {
|
||||
p = pilot_get(player_target);
|
||||
|
||||
if(player_target != PLAYER_ID) p = pilot_get(player_target);
|
||||
else p = NULL;
|
||||
if(p == NULL) player_target = PLAYER_ID; // No more pilot target.
|
||||
else {
|
||||
// There is still a pilot target.
|
||||
if(pilot_isDisabled(p)) c = &cInert;
|
||||
else if(pilot_isFlag(p, PILOT_HOSTILE)) c = &cHostile;
|
||||
else c = &cNeutral;
|
||||
|
@ -52,7 +52,7 @@ static int nvoice_stack = 0;
|
||||
static int mvoice_stack = 0;
|
||||
|
||||
// Volume.
|
||||
static ALfloat svolume = 0.5;
|
||||
static ALfloat svolume = 0.3;
|
||||
|
||||
static int sound_makeList(void);
|
||||
static int sound_load(ALuint* buffer, char* filename);
|
||||
|
@ -167,8 +167,6 @@ int space_canHyperspace(Pilot* p) {
|
||||
// Hyperspace, returns 0 if entering hyperspace, or the distance if not.
|
||||
int space_hyperspace(Pilot* p) {
|
||||
if(!space_canHyperspace(p)) return -1;
|
||||
// Too fast.
|
||||
//if(VMOD(p->solid->vel) > MAX_HYPERSPACE_VEL) return -2;
|
||||
|
||||
// Pilot is now going to get automatically ready for hyperspace.
|
||||
pilot_setFlag(p, PILOT_HYP_PREP);
|
||||
|
Loading…
Reference in New Issue
Block a user