[Add] Now you can define start mission in start.xml, also began initial tutorial level.
This commit is contained in:
parent
cccb8cbff3
commit
401ea9b4e5
5
TODO
5
TODO
@ -1,4 +1,7 @@
|
|||||||
Vital:
|
Vital:
|
||||||
|
|
||||||
|
-- CHECK MISSIONS OUT!! BORKED!!
|
||||||
|
|
||||||
-- New game improvements.
|
-- New game improvements.
|
||||||
-- Introductory screen (text + image?).
|
-- Introductory screen (text + image?).
|
||||||
-- Tutorial or small guide.
|
-- Tutorial or small guide.
|
||||||
@ -53,5 +56,5 @@ Minor:
|
|||||||
-- Possibly use Queso CGL
|
-- Possibly use Queso CGL
|
||||||
|
|
||||||
SOMEDAY!! MAYBE...:
|
SOMEDAY!! MAYBE...:
|
||||||
-- 3d models (not actually 3D, just no sprites).
|
-- 3d models (not actually a 3D perspective, just no sprites).
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Missions>
|
<Missions>
|
||||||
<mission name="Welcome">
|
<mission name="Tutorial">
|
||||||
<lua>welcome</lua>
|
<lua>tutorial</lua>
|
||||||
<flags>
|
<flags>
|
||||||
<unique>1</unique>
|
<unique>1</unique>
|
||||||
</flags>
|
</flags>
|
||||||
|
31
dat/missions/tutorial.lua
Normal file
31
dat/missions/tutorial.lua
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
--[[
|
||||||
|
-- The beginner player tutorial.
|
||||||
|
--
|
||||||
|
-- Does simple stuff like teach the player to fly around or use
|
||||||
|
-- her communications system.
|
||||||
|
--]]
|
||||||
|
|
||||||
|
-- Localization stuff, translators would work here.
|
||||||
|
lang = lephisto.lang()
|
||||||
|
if lang == "es" then
|
||||||
|
else -- Default English.
|
||||||
|
title = {}
|
||||||
|
title[1] = "Tutorial"
|
||||||
|
text = {}
|
||||||
|
text[1] = "Would you like to run the Tutorial to learn how to play Lephisto?"
|
||||||
|
misn_title = "Lephisto Tutorial"
|
||||||
|
misn_reward = "Knowledge of how to play the game."
|
||||||
|
misn_desc = "New Player Tutorial to learn how to survive in the universe."
|
||||||
|
end
|
||||||
|
|
||||||
|
function create()
|
||||||
|
if tk.yesno(title[1], text[1]) then
|
||||||
|
misn.accept()
|
||||||
|
|
||||||
|
-- Set basic mission information.
|
||||||
|
misn.setTitle(misn_title)
|
||||||
|
misn.setReward(misn_reward)
|
||||||
|
misn.setDesc(misn_desc)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -13,8 +13,9 @@
|
|||||||
</date>
|
</date>
|
||||||
<system>
|
<system>
|
||||||
<name>Delta Pavonis</name>
|
<name>Delta Pavonis</name>
|
||||||
<x>0</x>
|
<x>150</x>
|
||||||
<y>0</y>
|
<y>150</y>
|
||||||
</system>
|
</system>
|
||||||
|
<mission>Tutorial</mission>
|
||||||
</player>
|
</player>
|
||||||
</Start>
|
</Start>
|
||||||
|
@ -82,7 +82,7 @@ int mission_getID(char* name) {
|
|||||||
|
|
||||||
/* Get a MissionData based on ID. */
|
/* Get a MissionData based on ID. */
|
||||||
MissionData* mission_get(int id) {
|
MissionData* mission_get(int id) {
|
||||||
if((id <= 0) || (mission_nstack < id)) return NULL;
|
if((id < 0) || (id >= mission_nstack)) return NULL;
|
||||||
return &mission_stack[id];
|
return &mission_stack[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,6 +260,30 @@ void missions_bar(int faction, char* planet, char* sysname) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Starts a mission.
|
||||||
|
*
|
||||||
|
* Mission must still call misn.accept() to actually get added to the players
|
||||||
|
* active missions.
|
||||||
|
* @param name Name of the mission to start.
|
||||||
|
* @return 0 on success.
|
||||||
|
*/
|
||||||
|
int mission_start(char* name) {
|
||||||
|
Mission mission;
|
||||||
|
MissionData* mdat;
|
||||||
|
|
||||||
|
/* Try to get the mission. */
|
||||||
|
mdat = mission_get(mission_getID(name));
|
||||||
|
if(mdat == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* Try to run the mission.
|
||||||
|
mission_init(&mission, mdat, 0);
|
||||||
|
mission_cleanup(&mission); /* Clean up in case not accepted. */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Mark all active systems that need marking. */
|
/* Mark all active systems that need marking. */
|
||||||
void mission_sysMark(void) {
|
void mission_sysMark(void) {
|
||||||
int i;
|
int i;
|
||||||
|
@ -76,6 +76,7 @@ Mission* missions_computer(int* n, int faction, char* planet, char* sysname);
|
|||||||
/* Player accepted mission - mission computer. */
|
/* Player accepted mission - mission computer. */
|
||||||
int mission_accept(Mission* mission);
|
int mission_accept(Mission* mission);
|
||||||
void missions_bar(int faction, char* planet, char* sysname);
|
void missions_bar(int faction, char* planet, char* sysname);
|
||||||
|
int missions_start(char* name);
|
||||||
|
|
||||||
/* Misc. */
|
/* Misc. */
|
||||||
void missions_update(const double dt);
|
void missions_update(const double dt);
|
||||||
|
20
src/player.c
20
src/player.c
@ -56,6 +56,7 @@ Pilot* player = NULL; /**< The player. */
|
|||||||
static Ship* player_ship = NULL; /**< Temp ship to hold when naming it. */
|
static Ship* player_ship = NULL; /**< Temp ship to hold when naming it. */
|
||||||
static double player_px, player_py, player_vx, player_vy, player_dir; /**< More hack. */
|
static double player_px, player_py, player_vx, player_vy, player_dir; /**< More hack. */
|
||||||
static int player_credits = 0; /**< Temp hack on create. */
|
static int player_credits = 0; /**< Temp hack on create. */
|
||||||
|
static char* player_mission = NULL; /**< More hack. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Player sounds.
|
* Player sounds.
|
||||||
@ -274,6 +275,14 @@ void player_new(void) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
intro_display();
|
intro_display();
|
||||||
|
|
||||||
|
/* Add the mission if found. */
|
||||||
|
if(player_mission != NULL) {
|
||||||
|
if(mission_start(player_mission) < 0)
|
||||||
|
WARN("Failed to run start mission '%s'.", player_mission);
|
||||||
|
free(player_mission);
|
||||||
|
player_mission = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -288,7 +297,9 @@ static int player_newMake(void) {
|
|||||||
int l, h, tl, th;
|
int l, h, tl, th;
|
||||||
double x, y;
|
double x, y;
|
||||||
|
|
||||||
|
/* Sane defaults. */
|
||||||
sysname = NULL;
|
sysname = NULL;
|
||||||
|
player_mission = NULL;
|
||||||
|
|
||||||
buf = pack_readfile(DATA, START_DATA, &bufsize);
|
buf = pack_readfile(DATA, START_DATA, &bufsize);
|
||||||
|
|
||||||
@ -339,10 +350,19 @@ static int player_newMake(void) {
|
|||||||
xmlr_int(tmp, "high", th);
|
xmlr_int(tmp, "high", th);
|
||||||
} while(xml_nextNode(tmp));
|
} while(xml_nextNode(tmp));
|
||||||
}
|
}
|
||||||
|
/* Check for mission. */
|
||||||
|
if(xml_isNode(cur, "mission")) {
|
||||||
|
if(player_mission != NULL) {
|
||||||
|
WARN("start.xml already contains a mission node!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
player_mission = strdup(xml_get(cur));
|
||||||
|
}
|
||||||
} while((cur = cur->next));
|
} while((cur = cur->next));
|
||||||
}
|
}
|
||||||
}while((node = node->next));
|
}while((node = node->next));
|
||||||
|
|
||||||
|
/* Clean up. */
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user