summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2011-02-22 06:45:48 +0100
committerBardur Arantsson <bardur@scientician.net>2012-03-29 21:22:23 +0200
commitaef0a9a6670ec219c3fc00e9cd9bc30458a5cab5 (patch)
tree46834896de02d7c430360c45a59a1c861f421936 /src
parent3b4cbce560800a5cf8326904d70623b6bb910241 (diff)
Refactor: Generalize dynamic quest description for C-based quests
Diffstat (limited to 'src')
-rw-r--r--src/cmd4.c29
-rw-r--r--src/plots.h1
-rw-r--r--src/q_rand.c30
-rw-r--r--src/tables.c26
-rw-r--r--src/types.h2
5 files changed, 63 insertions, 25 deletions
diff --git a/src/cmd4.c b/src/cmd4.c
index f6f90247..fdce00cd 100644
--- a/src/cmd4.c
+++ b/src/cmd4.c
@@ -4225,34 +4225,13 @@ static void do_cmd_knowledge_quests(void)
/* Dynamic quests */
if (quest[i].dynamic_desc)
{
- /* Random quests */
- if (i == QUEST_RANDOM)
+ /* C type quests */
+ if (quest[i].type == HOOK_TYPE_C)
{
- /**/
- if (!(dungeon_flags1 & DF1_PRINCIPAL)) continue;
- if ((dun_level < 1) || (dun_level >= MAX_RANDOM_QUEST)) continue;
- if (!random_quests[dun_level].type) continue;
- if (random_quests[dun_level].done) continue;
- if (p_ptr->inside_quest) continue;
- if (!dun_level) continue;
-
- if (!is_randhero(dun_level))
+ if (!quest[i].gen_desc(fff))
{
- fprintf(fff, "#####yCaptured princess!\n");
- fprintf(fff, "A princess is being held prisoner and tortured here!\n");
- fprintf(fff, "Save her from the horrible %s.\n",
- r_info[random_quests[dun_level].r_idx].name + r_name);
+ continue;
}
- else
- {
- fprintf(fff, "#####yLost sword!\n");
- fprintf(fff, "An adventurer lost his sword to a bunch of %s!\n",
- r_info[random_quests[dun_level].r_idx].name + r_name);
- fprintf(fff, "Kill them all to get it back.\n");
- }
- fprintf(fff, "Number: %d, Killed: %ld.\n",
- random_quests[dun_level].type, (long int) quest[QUEST_RANDOM].data[0]);
- fprintf(fff, "\n");
}
/* MUST be a lua quest */
else
diff --git a/src/plots.h b/src/plots.h
index d21241c2..a1a11e6c 100644
--- a/src/plots.h
+++ b/src/plots.h
@@ -7,6 +7,7 @@ extern bool_ quest_null_hook(int q);
/******* Random Quests ********/
extern bool_ is_randhero(int level);
extern bool_ quest_random_init_hook(int q_idx);
+extern bool_ quest_random_describe(FILE *fff);
/******* Plot main ********/
extern bool_ quest_necro_init_hook(int q_idx);
diff --git a/src/q_rand.c b/src/q_rand.c
index 84f7d3d3..50617bb8 100644
--- a/src/q_rand.c
+++ b/src/q_rand.c
@@ -429,6 +429,36 @@ bool_ quest_random_dump_hook(char *fmt)
return (FALSE);
}
+
+bool_ quest_random_describe(FILE *fff)
+{
+ if (!(dungeon_flags1 & DF1_PRINCIPAL)) return FALSE;
+ if ((dun_level < 1) || (dun_level >= MAX_RANDOM_QUEST)) return FALSE;
+ if (!random_quests[dun_level].type) return FALSE;
+ if (random_quests[dun_level].done) return FALSE;
+ if (p_ptr->inside_quest) return FALSE;
+ if (!dun_level) return FALSE;
+
+ if (!is_randhero(dun_level))
+ {
+ fprintf(fff, "#####yCaptured princess!\n");
+ fprintf(fff, "A princess is being held prisoner and tortured here!\n");
+ fprintf(fff, "Save her from the horrible %s.\n",
+ r_info[random_quests[dun_level].r_idx].name + r_name);
+ }
+ else
+ {
+ fprintf(fff, "#####yLost sword!\n");
+ fprintf(fff, "An adventurer lost his sword to a bunch of %s!\n",
+ r_info[random_quests[dun_level].r_idx].name + r_name);
+ fprintf(fff, "Kill them all to get it back.\n");
+ }
+ fprintf(fff, "Number: %d, Killed: %ld.\n",
+ random_quests[dun_level].type, (long int) quest[QUEST_RANDOM].data[0]);
+ fprintf(fff, "\n");
+ return TRUE;
+}
+
bool_ quest_random_init_hook(int q_idx)
{
add_hook(HOOK_MONSTER_DEATH, quest_random_death_hook, "rand_death");
diff --git a/src/tables.c b/src/tables.c
index f5aac276..e976e234 100644
--- a/src/tables.c
+++ b/src/tables.c
@@ -3601,6 +3601,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_null_hook,
{0, 0},
+ NULL,
},
{
FALSE,
@@ -3625,6 +3626,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_necro_init_hook,
{0, 0},
+ NULL,
},
{
FALSE,
@@ -3649,6 +3651,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_sauron_init_hook,
{0, 0},
+ NULL,
},
{
FALSE,
@@ -3673,6 +3676,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_morgoth_init_hook,
{0, 0},
+ NULL,
},
/* Bree plot */
@@ -3699,6 +3703,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_thieves_init_hook,
{0, 0},
+ NULL,
},
{
@@ -3724,6 +3729,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_random_init_hook,
{0, 0},
+ quest_random_describe,
},
{
@@ -3749,6 +3755,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_hobbit_init_hook,
{0, 0},
+ NULL,
},
{
@@ -3774,6 +3781,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_nazgul_init_hook,
{0, 0},
+ NULL,
},
{
@@ -3799,6 +3807,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_troll_init_hook,
{FALSE, 0},
+ NULL,
},
{
@@ -3824,6 +3833,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_wight_init_hook,
{FALSE, 0},
+ NULL,
},
/* Lorien plot */
@@ -3850,6 +3860,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_spider_init_hook,
{0, 0},
+ NULL,
},
{
FALSE,
@@ -3874,6 +3885,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_poison_init_hook,
{0, 0},
+ NULL,
},
/* Other quests */
{
@@ -3899,6 +3911,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_narsil_init_hook,
{0, 0},
+ NULL,
},
/* Gondolin plot */
{
@@ -3924,6 +3937,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_eol_init_hook,
{0, 0},
+ NULL,
},
{
FALSE,
@@ -3948,6 +3962,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_nirnaeth_init_hook,
{0, 0},
+ NULL,
},
{
FALSE,
@@ -3972,6 +3987,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_invasion_init_hook,
{0, 0},
+ NULL,
},
/* Minas Anor Plot*/
{
@@ -3997,6 +4013,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_between_init_hook,
{0, 0},
+ NULL,
},
{
FALSE,
@@ -4021,6 +4038,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_one_init_hook,
{0, 0},
+ NULL,
},
{
@@ -4046,6 +4064,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_shroom_init_hook,
{0, 0},
+ NULL,
},
{
@@ -4071,6 +4090,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_thrain_init_hook,
{0, 0},
+ NULL,
},
/* The 2 ultra endings go here */
@@ -4097,6 +4117,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_ultra_good_init_hook,
{0, 0},
+ NULL,
},
{
FALSE,
@@ -4121,6 +4142,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_ultra_evil_init_hook,
{0, 0},
+ NULL,
},
/* More Lorien */
{
@@ -4146,6 +4168,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_wolves_init_hook,
{0, 0},
+ NULL,
},
/* More Gondolin */
{
@@ -4171,6 +4194,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_dragons_init_hook,
{0, 0},
+ NULL,
},
/* More Minas Anor */
{
@@ -4196,6 +4220,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_haunted_init_hook,
{0, 0},
+ NULL,
},
/* Khazad-Dum Plot*/
{
@@ -4221,6 +4246,7 @@ quest_type quest_init_tome[MAX_Q_IDX_INIT] =
HOOK_TYPE_C,
quest_evil_init_hook,
{0, 0},
+ NULL,
},
};
diff --git a/src/types.h b/src/types.h
index e619c182..49acb383 100644
--- a/src/types.h
+++ b/src/types.h
@@ -2254,6 +2254,8 @@ struct quest_type
bool_ (*init)(int q); /* Function that takes care of generating hardcoded quests */
s32b data[4]; /* Various datas used by the quests */
+
+ bool_ (*gen_desc)(FILE *fff); /* Function for generating description. */
};
typedef struct random_quest random_quest;
struct random_quest