summaryrefslogtreecommitdiff
path: root/src/q_main.c
blob: a13b0790681c62551989d0c75997bad821726044 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
bool_ quest_main_monsters_hook(char *fmt)
{
	s32b r_idx;
	r_idx = get_next_arg(fmt);

	/* Sauron */
	if (r_idx == 860)
	{
		/* No Sauron until Necromancer dies */
		if (r_info[819].max_num) return TRUE;
	}
	/* Morgoth */
	else if (r_idx == 862)
	{
		/* No Morgoth until Sauron dies */
		if (r_info[860].max_num) return TRUE;
	}
	return FALSE;
}
bool_ quest_morgoth_hook(char *fmt)
{
	/* Using test_monster_name() here would be a lot less ugly, but would take much more time */
	monster_race *r_ptr = &r_info[862];

	/* Need to kill him */
	if (!r_ptr->max_num)
	{
		/* Total winner */
		total_winner = WINNER_NORMAL;
		has_won = WINNER_NORMAL;
		quest[QUEST_MORGOTH].status = QUEST_STATUS_FINISHED;

		/* Redraw the "title" */
		p_ptr->redraw |= (PR_TITLE);

		/* Congratulations */
		if (quest[QUEST_ONE].status == QUEST_STATUS_FINISHED)
		{
			cmsg_print(TERM_L_GREEN, "*** CONGRATULATIONS ***");
			cmsg_print(TERM_L_GREEN, "You have banished Morgoth's foul spirit from Ea, and as you watch, a cleansing");
			cmsg_print(TERM_L_GREEN, "wind roars through the dungeon, dispersing the nether mists around where the");
			cmsg_print(TERM_L_GREEN, "body fell. You feel thanks, and a touch of sorrow, from the Valar");
			cmsg_print(TERM_L_GREEN, "for your deed. You will be forever heralded, your deed forever legendary.");
			cmsg_print(TERM_L_GREEN, "You may retire (commit suicide) when you are ready.");
		}
		else
		{
			cmsg_print(TERM_VIOLET, "*** CONGRATULATIONS ***");
			cmsg_print(TERM_VIOLET, "You have banished Morgoth from Arda, and made Ea a safer place.");
			cmsg_print(TERM_VIOLET, "As you look down at the dispersing mists around Morgoth, a sudden intuition");
			cmsg_print(TERM_VIOLET, "grasps you. Fingering the One Ring, you gather the nether mists around");
			cmsg_print(TERM_VIOLET, "yourself, and inhale deeply their seductive power.");
			cmsg_print(TERM_VIOLET, "You will be forever feared, your orders forever obeyed.");
			cmsg_print(TERM_VIOLET, "You may retire (commit suicide) when you are ready.");
		}

		/* Continue the plot(maybe) */
		del_hook(HOOK_MONSTER_DEATH, quest_morgoth_hook);
		process_hooks_restart = TRUE;

		/* Either ultra good if the one Ring is destroyed, or ultra evil if used */
		if (quest[QUEST_ONE].status == QUEST_STATUS_FINISHED)
			*(quest[QUEST_MORGOTH].plot) = QUEST_ULTRA_GOOD;
		else
			*(quest[QUEST_MORGOTH].plot) = QUEST_ULTRA_EVIL;
		quest[*(quest[QUEST_MORGOTH].plot)].init(*(quest[QUEST_MORGOTH].plot));
	}
	return (FALSE);
}
bool_ quest_morgoth_dump_hook(char *fmt)
{
	if (quest[QUEST_MORGOTH].status >= QUEST_STATUS_COMPLETED)
	{
		if (quest[QUEST_ONE].status == QUEST_STATUS_FINISHED)
			fprintf(hook_file, "\n You saved Arda and became a famed %s.", sp_ptr->winner);
		else
			fprintf(hook_file, "\n You became a new force of darkness and enslaved all free people.");
	}
	return (FALSE);
}
bool_ quest_morgoth_init_hook(int q_idx)
{
	if ((quest[QUEST_MORGOTH].status >= QUEST_STATUS_TAKEN) && (quest[QUEST_MORGOTH].status < QUEST_STATUS_FINISHED))
	{
		add_hook(HOOK_MONSTER_DEATH, quest_morgoth_hook, "morgort_death");
	}
	add_hook(HOOK_CHAR_DUMP, quest_morgoth_dump_hook, "morgoth_dump");
	add_hook(HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster");
	return (FALSE);
}

bool_ quest_sauron_hook(char *fmt)
{
	/* Using test_monster_name() here would be a lot less ugly, but would take much more time */
	monster_race *r_ptr = &r_info[860];

	/* Need to kill him */
	if (!r_ptr->max_num)
	{
		cmsg_print(TERM_YELLOW, "Well done! You are on the way to slaying Morgoth...");
		quest[QUEST_SAURON].status = QUEST_STATUS_FINISHED;

		quest[QUEST_MORGOTH].status = QUEST_STATUS_TAKEN;
		quest_describe(QUEST_MORGOTH);

		del_hook(HOOK_MONSTER_DEATH, quest_sauron_hook);
		add_hook(HOOK_MONSTER_DEATH, quest_morgoth_hook, "morgort_death");
		*(quest[QUEST_SAURON].plot) = QUEST_MORGOTH;
		quest_morgoth_init_hook(QUEST_MORGOTH);

		process_hooks_restart = TRUE;
	}
	return (FALSE);
}

bool_ quest_sauron_resurect_hook(char *fmt)
{
	s32b m_idx = get_next_arg(fmt);
	monster_type *m_ptr = &m_list[m_idx];
	monster_race *r_ptr = &r_info[m_ptr->r_idx];

	if ((r_ptr->flags7 & RF7_NAZGUL) && r_info[860].max_num)
	{
		msg_format("Somehow you feel %s is not totally destroyed...", (r_ptr->flags1 & RF1_FEMALE ? "she" : "he"));
		r_ptr->max_num = 1;
	}
	else if ((m_ptr->r_idx == 860) && (quest[QUEST_ONE].status < QUEST_STATUS_FINISHED))
	{
		msg_print("Sauron will not be permanently defeated until the One Ring is either destroyed or used...");
		r_ptr->max_num = 1;
	}
	return FALSE;
}

bool_ quest_sauron_init_hook(int q_idx)
{
	if ((quest[QUEST_SAURON].status >= QUEST_STATUS_TAKEN) && (quest[QUEST_SAURON].status < QUEST_STATUS_FINISHED))
	{
		add_hook(HOOK_MONSTER_DEATH, quest_sauron_hook, "sauron_death");
	}
	add_hook(HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster");
	add_hook(HOOK_MONSTER_DEATH, quest_sauron_resurect_hook, "sauron_resurect_death");
	return (FALSE);
}

bool_ quest_necro_hook(char *fmt)
{
	/* Using test_monster_name() here would be a lot less ugly, but would take much more time */
	monster_race *r_ptr = &r_info[819];

	/* Need to kill him */
	if (!r_ptr->max_num)
	{
		cmsg_print(TERM_YELLOW, "You see the spirit of the necromancer rise and flee...");
		cmsg_print(TERM_YELLOW, "It looks like it was indeed Sauron...");
		cmsg_print(TERM_YELLOW, "You should report that to Galadriel as soon as possible.");

		quest[QUEST_NECRO].status = QUEST_STATUS_FINISHED;

		*(quest[QUEST_NECRO].plot) = QUEST_ONE;
		quest[*(quest[QUEST_NECRO].plot)].init(*(quest[QUEST_NECRO].plot));

		del_hook(HOOK_MONSTER_DEATH, quest_necro_hook);
		process_hooks_restart = TRUE;
	}
	return (FALSE);
}
bool_ quest_necro_init_hook(int q_idx)
{
	if ((quest[QUEST_NECRO].status >= QUEST_STATUS_TAKEN) && (quest[QUEST_NECRO].status < QUEST_STATUS_FINISHED))
	{
		add_hook(HOOK_MONSTER_DEATH, quest_necro_hook, "necro_death");
	}
	add_hook(HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster");
	return (FALSE);
}