- [+] bug in movement speed display for monsters

- [+] bug: curtime getting past 23:59.  need it to wrap around.
* [+] track # days spent.
- [+] need to save gametime!
This commit is contained in:
Rob Pearce 2011-08-25 09:01:28 +00:00
parent 52f6fd21c3
commit 1f721ed03c
7 changed files with 48 additions and 7 deletions

1
defs.h
View File

@ -291,6 +291,7 @@
#define ANYROOM (-9770)
#define FALLTHRU (-8765) // for walkdambp
#define TICK_INTERVAL (20)
#define DAYSECS (86400) // # seconds in a day

6
io.c
View File

@ -8285,9 +8285,9 @@ void showlfstats(lifeform_t *lf, int showall) {
if (lorelev >= PR_NOVICE) unsetcol(mainwin, lorecol);
}
getspeednameshort(getactspeed(player), actbuf);
getspeednameshort(getmovespeed(player), movebuf);
if (!strcmp(actbuf, movebuf)) {
getspeednameshort(getactspeed(lf), actbuf);
getspeednameshort(getmovespeed(lf), movebuf);
if (streq(actbuf, movebuf)) {
sprintf(buf, "%s", actbuf);
capitalise(buf);
} else {

1
lf.c
View File

@ -15061,6 +15061,7 @@ void initskills(void) {
addskilldesc(SK_SS_MODIFICATION, PR_EXPERT, "Allows you to cast Modification spells up to level 5.", B_FALSE);
addskilldesc(SK_SS_MODIFICATION, PR_MASTER, "Allows you to cast Modification spells up to level 6.", B_FALSE);
addskill(SK_SS_MENTAL, "Psionics", "Boosts casting of spells from this school.", 50);
addskilldesc(SK_SS_MENTAL, PR_INEPT, "- Each rank gives you a 10%% chance to learn a new psionic ability when levelling up.", B_FALSE);
addskilldesc(SK_SS_MENTAL, PR_NOVICE, "Allows you to cast Psionic spells up to level 1.", B_FALSE);
addskilldesc(SK_SS_MENTAL, PR_BEGINNER, "Allows you to cast Psionic spells up to level 2.", B_FALSE);
addskilldesc(SK_SS_MENTAL, PR_ADEPT, "Allows you to cast Psionic spells up to level 3.", B_FALSE);

19
nexus.c
View File

@ -85,8 +85,10 @@ int obdb = B_FALSE;
enum GAMEMODE gamemode = GM_FIRST;
long curtime = 0;
long timeleft = 0;
long curtime = 0; // # current game clock (in seconds)
long gamedays = 0; // # game days passed since start of game
long gamesecs = 0; // # game seconds passed since start of game
long timeleft = 0; // # secs remaining for which we need to process events
extern int statdirty;
@ -306,7 +308,7 @@ int main(int argc, char **argv) {
getplayernamefull(pname);
sprintf(welcomemsg, "Greetings %s, welcome to %snexus!", pname, newworld ? "the new " : "");
// 00:00 - 23:59
curtime = rnd(0,86399);
curtime = rnd(0,DAYSECS-1);
} else {
sprintf(welcomemsg, "Welcome back!");
@ -1534,6 +1536,17 @@ void timeeffectsworld(map_t *map, int updategametime) {
if (updategametime) {
// inc game time
curtime += firstlftime;
// don't let it get higher than 23:59
while (curtime >= DAYSECS) {
curtime -= DAYSECS;
}
// inc total gametime passed
gamesecs += firstlftime;
while (gamesecs >= DAYSECS) {
gamesecs -= DAYSECS;
gamedays++;
}
}
if (db) dblog("cur time is %ld\n",curtime);

View File

@ -8803,18 +8803,21 @@ void initobjects(void) {
addflag(lastot->flags, F_GOESON, BP_HEAD, NA, NA, NULL);
addflag(lastot->flags, F_ARMOURRATING, 1, NA, NA, NULL);
addflag(lastot->flags, F_OBHP, 3, 3, NA, NULL);
addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL);
addot(OT_PIRATEHAT, "tricorne", "A three cornered hat with a skull and crossbones emblem.", MT_CLOTH, 1, OC_ARMOUR, SZ_SMALL);
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, RR_UNCOMMON, NULL);
addflag(lastot->flags, F_GOESON, BP_HEAD, NA, NA, NULL);
addflag(lastot->flags, F_ARMOURRATING, 1, NA, NA, NULL);
addflag(lastot->flags, F_OBHP, 2, 2, NA, NULL);
addflag(lastot->flags, F_SCARY, 2, NA, NA, NULL);
addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL);
addot(OT_CAP, "cap", "Close-fitting headwear with a short shade visor at the front.", MT_CLOTH, 1, OC_ARMOUR, SZ_SMALL);
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, RR_COMMON, NULL);
addflag(lastot->flags, F_RARITY, H_FOREST, 100, RR_COMMON, NULL);
addflag(lastot->flags, F_GOESON, BP_HEAD, NA, NA, NULL);
addflag(lastot->flags, F_ARMOURRATING, 1, NA, NA, NULL);
addflag(lastot->flags, F_OBHP, 3, 3, NA, NULL);
addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL);
addot(OT_GASMASK, "gas mask", "A full face mask which protects the wearer from toxic gasses.", MT_METAL, 3.5, OC_ARMOUR, SZ_SMALL);
addflag(lastot->flags, F_RARITY, H_DUNGEON, 75, RR_UNCOMMON, NULL);
addflag(lastot->flags, F_GOESON, BP_HEAD, NA, NA, NULL);
@ -8823,6 +8826,7 @@ void initobjects(void) {
addflag(lastot->flags, F_OBHP, 10, 10, NA, NULL);
addflag(lastot->flags, F_EQUIPCONFER, F_DTIMMUNE, DT_POISONGAS, NA, NULL);
addflag(lastot->flags, F_EQUIPCONFER, F_VISRANGEMOD, -5, NA, NULL);
addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL);
addot(OT_HELM, "helmet", "A plain metal helmet.", MT_METAL, 2, OC_ARMOUR, SZ_SMALL);
addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, RR_COMMON, NULL);
addflag(lastot->flags, F_GOESON, BP_HEAD, NA, NA, NULL);

22
save.c
View File

@ -25,6 +25,8 @@ extern knowledge_t *knowledge;
extern region_t *firstregion,*lastregion;
extern regionoutline_t *firstregionoutline,*lastregionoutline;
extern long curtime, gamedays, gamesecs;
extern enum GAMEMODE gamemode;
int loadall(void) {
@ -40,13 +42,15 @@ int loadall(void) {
return B_TRUE;
}
// load region outlines first.
// load region outlines
if (loadregions()) {
// this isn't an error - just means no savegames
if (db) dblog("No region data found.");
return B_FALSE;
}
// for each map file in directory
while ((ent = readdir(dir)) != NULL) {
char *p;
@ -692,6 +696,11 @@ int loadsavegame(void) {
printf("Error opening savegame file '%s'",ent->d_name);
exit(1);
}
// load world data
if (loadworlddata(f)) {
printf("Error load world data from file '%s'", ent->d_name);
exit(1);
}
if (!loadlf(f, NULL)) {
printf("Error loading player from file '%s'",ent->d_name);
exit(1);
@ -725,6 +734,10 @@ int savevars(FILE *f) {
return B_FALSE;
}
int loadworlddata(FILE *f) {
fscanf(f, "timedata:%ld,%ld,%ld\n",&curtime,&gamedays,&gamesecs);
return B_FALSE;
}
int saveflagpile(FILE *f, flagpile_t *fp) {
flag_t *fl;
@ -811,6 +824,7 @@ int savegame(void) {
FILE *f;
char buf[BUFLEN];
int rv;
rv = saveregions();
if (rv) {
msg("Could not save region data.");
@ -831,6 +845,7 @@ int savegame(void) {
msg("Could not open save file!");
return B_TRUE;
}
saveworlddata(f);
savelf(f, player);
saveknowledge(f);
savevars(f);
@ -1016,6 +1031,11 @@ int saveregions(void) {
return B_FALSE;
}
int saveworlddata(FILE *f) {
fprintf(f, "timedata:%ld,%ld,%ld\n",curtime,gamedays,gamesecs);
return B_FALSE;
}
int showhiscores(lifeform_t *lf, int min, int max) {
sqlite3 *db;
int rc;

2
save.h
View File

@ -8,6 +8,7 @@ map_t *loadmap(char *basefile);
int loadob(FILE *f, obpile_t *op, long *id);
int loadregions(void);
int loadsavegame(void);
int loadworlddata(FILE *f);
int saveflagpile(FILE *f, flagpile_t *fp);
int saveknowledge(FILE *f);
int savelf(FILE *f, lifeform_t *l);
@ -15,5 +16,6 @@ int savegame(void);
int savemap(map_t *m);
int saveob(FILE *f, object_t *o);
int saveregions(void);
int saveworlddata(FILE *f);
int showhiscores(lifeform_t *lf, int min, int max);
int writehiscore(lifeform_t *lf, int *rank);