1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program; if not, write to the Free Software |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
|
|
25 | |
24 | |
26 | /* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and |
25 | /* Oct 3, 1995 - Code laid down for initial gods, priest alignment, and |
27 | * monster race initialization. b.t. |
26 | * monster race initialization. b.t. |
28 | */ |
27 | */ |
29 | |
28 | |
… | |
… | |
38 | |
37 | |
39 | /** |
38 | /** |
40 | * Returns the id of specified god. |
39 | * Returns the id of specified god. |
41 | */ |
40 | */ |
42 | int |
41 | int |
43 | lookup_god_by_name (const char *name) |
42 | lookup_god_by_name (shstr_cmp name) |
44 | { |
43 | { |
45 | int godnr = -1; |
44 | if (name) |
46 | size_t nmlen = strlen (name); |
|
|
47 | |
|
|
48 | if (name && strcmp (name, "none")) |
|
|
49 | { |
|
|
50 | godlink *gl; |
|
|
51 | |
|
|
52 | for (gl = first_god; gl; gl = gl->next) |
45 | for (godlink *gl = first_god; gl; gl = gl->next) |
53 | if (!strncmp (name, gl->name, MIN ((size_t) strlen (gl->name), nmlen))) |
46 | if (gl->name == name) |
54 | break; |
|
|
55 | if (gl) |
|
|
56 | godnr = gl->id; |
47 | return gl->id; |
57 | } |
48 | |
58 | return godnr; |
49 | return -1; |
59 | } |
50 | } |
60 | |
51 | |
61 | /** |
52 | /** |
62 | * Returns pointer to specified god's object through pntr_to_god_obj.. |
53 | * Returns pointer to specified god's object through pntr_to_god_obj.. |
63 | */ |
54 | */ |
64 | object * |
55 | object * |
65 | find_god (const char *name) |
56 | find_god (shstr_cmp name) |
66 | { |
57 | { |
67 | object *god = NULL; |
|
|
68 | |
|
|
69 | if (name) |
58 | if (name) |
70 | { |
|
|
71 | godlink *gl; |
|
|
72 | |
|
|
73 | for (gl = first_god; gl; gl = gl->next) |
59 | for (godlink *gl = first_god; gl; gl = gl->next) |
74 | if (!strcmp (name, gl->name)) |
60 | if (gl->name == name) |
75 | break; |
|
|
76 | if (gl) |
|
|
77 | god = pntr_to_god_obj (gl); |
61 | return pntr_to_god_obj (gl); |
78 | } |
62 | |
79 | return god; |
63 | return 0; |
|
|
64 | } |
|
|
65 | |
|
|
66 | /** |
|
|
67 | * Returns a string that is the name of the god that should be natively worshipped by a |
|
|
68 | * creature of who has race *race |
|
|
69 | * if we can't find a god that is appropriate, we return NULL |
|
|
70 | */ |
|
|
71 | static shstr_tmp |
|
|
72 | get_god_for_race (shstr_cmp race) |
|
|
73 | { |
|
|
74 | if (race) |
|
|
75 | for (godlink *gl = first_god; gl; gl = gl->next) |
|
|
76 | if (gl->arch->race == race) |
|
|
77 | return gl->name; |
|
|
78 | |
|
|
79 | return shstr_tmp (); |
80 | } |
80 | } |
81 | |
81 | |
82 | /** |
82 | /** |
83 | * Determines if op worships a god. |
83 | * Determines if op worships a god. |
84 | * Returns the godname if they do or "none" if they have no god. |
84 | * Returns the godname if they do or "none" if they have no god. |
85 | * In the case of an NPC, if they have no god, we try and guess |
85 | * In the case of an NPC, if they have no god, we try and guess |
86 | * who they should worship based on their race. If that fails we |
86 | * who they should worship based on their race. If that fails we |
87 | * give them a random one. |
87 | * give them a random one. |
88 | */ |
88 | */ |
89 | |
89 | shstr_tmp |
90 | const char * |
|
|
91 | determine_god (object *op) |
90 | determine_god (object *op) |
92 | { |
91 | { |
93 | int godnr = -1; |
|
|
94 | const char *godname; |
|
|
95 | |
|
|
96 | /* spells */ |
92 | /* spells */ |
97 | if ((op->type == SPELL || op->type == SPELL_EFFECT) && op->title) |
93 | if ((op->type == SPELL || op->type == SPELL_EFFECT) && op->title) |
98 | { |
|
|
99 | if (lookup_god_by_name (op->title) >= 0) |
94 | if (lookup_god_by_name (op->title) >= 0) |
100 | return op->title; |
95 | return op->title; |
|
|
96 | |
|
|
97 | if (!op->is_player () && op->flag [FLAG_ALIVE]) |
101 | } |
98 | { |
102 | |
|
|
103 | if (op->type != PLAYER && QUERY_FLAG (op, FLAG_ALIVE)) |
|
|
104 | { |
|
|
105 | |
|
|
106 | /* find a god based on race */ |
99 | /* find a god based on race */ |
107 | if (!op->title) |
100 | if (!op->title) |
108 | { |
|
|
109 | if (op->race != NULL) |
|
|
110 | { |
|
|
111 | godname = get_god_for_race (op->race); |
101 | op->title = get_god_for_race (op->race); |
112 | if (godname != NULL) |
|
|
113 | { |
|
|
114 | op->title = godname; |
|
|
115 | } |
|
|
116 | } |
|
|
117 | } |
|
|
118 | |
102 | |
119 | /* find a random god */ |
103 | /* find a random god */ |
120 | if (!op->title) |
104 | if (!op->title) |
121 | { |
105 | { |
122 | godlink *gl = first_god; |
|
|
123 | |
|
|
124 | godnr = rndm (1, gl->id); |
106 | int godnr = rndm (1, first_god->id); |
125 | while (gl) |
107 | |
126 | { |
108 | for (godlink *gl = first_god; gl; gl = gl->next) |
127 | if (gl->id == godnr) |
109 | if (gl->id == godnr) |
|
|
110 | { |
|
|
111 | op->title = gl->name; |
128 | break; |
112 | break; |
129 | gl = gl->next; |
|
|
130 | } |
113 | } |
131 | op->title = gl->name; |
|
|
132 | } |
114 | } |
133 | |
115 | |
134 | return op->title; |
116 | return op->title; |
135 | } |
117 | } |
136 | |
|
|
137 | |
118 | |
138 | /* The god the player worships is in the praying skill (native skill |
119 | /* The god the player worships is in the praying skill (native skill |
139 | * not skill tool). Since a player can only have one instance of |
120 | * not skill tool). Since a player can only have one instance of |
140 | * that skill, once we find it, we can return, either with the |
121 | * that skill, once we find it, we can return, either with the |
141 | * title or "none". |
122 | * title or "none". |
142 | */ |
123 | */ |
143 | if (op->type == PLAYER) |
124 | if (op->type == PLAYER) |
144 | { |
|
|
145 | object *tmp; |
|
|
146 | |
|
|
147 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
125 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
148 | if (tmp->type == SKILL && tmp->subtype == SK_PRAYING) |
126 | if (tmp->type == SKILL && tmp->subtype == SK_PRAYING) |
149 | { |
127 | { |
150 | if (tmp->title) |
128 | if (tmp->title) |
151 | return (tmp->title); |
129 | return tmp->title; |
152 | else |
130 | |
153 | return ("none"); |
131 | break; |
154 | } |
132 | } |
155 | } |
133 | |
156 | return ("none"); |
134 | return shstr_none; |
157 | } |
135 | } |
158 | |
136 | |
159 | /** |
137 | /** |
160 | * Returns 1 if s1 and s2 are the same - either both NULL, or strcmp( ) == 0 |
138 | * Returns 1 if s1 and s2 are the same - either both NULL, or strcmp( ) == 0 |
161 | */ |
139 | */ |
162 | static int |
140 | static int |
163 | same_string (const char *s1, const char *s2) |
141 | same_string (const char *s1, const char *s2) |
164 | { |
142 | { |
165 | if (s1 == NULL) |
143 | if (s1 == s2) |
166 | if (s2 == NULL) |
|
|
167 | return 1; |
144 | return 1; |
|
|
145 | else if (s1 && s2) |
|
|
146 | return !strcmp (s1, s2); |
168 | else |
147 | else |
169 | return 0; |
|
|
170 | else if (s2 == NULL) |
|
|
171 | return 0; |
148 | return 0; |
172 | else |
|
|
173 | return strcmp (s1, s2) == 0; |
|
|
174 | } |
149 | } |
175 | |
|
|
176 | |
150 | |
177 | /** |
151 | /** |
178 | * Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively). |
152 | * Checks for any occurrence of the given 'item' in the inventory of 'op' (recursively). |
179 | * Any matching items in the inventory are deleted, and a |
153 | * Any matching items in the inventory are deleted, and a |
180 | * message is displayed to the player. |
154 | * message is displayed to the player. |
… | |
… | |
193 | |
167 | |
194 | if (tmp->type == item->type |
168 | if (tmp->type == item->type |
195 | && same_string (tmp->name, item->name) |
169 | && same_string (tmp->name, item->name) |
196 | && same_string (tmp->title, item->title) && same_string (tmp->msg, item->msg) && same_string (tmp->slaying, item->slaying)) |
170 | && same_string (tmp->title, item->title) && same_string (tmp->msg, item->msg) && same_string (tmp->slaying, item->slaying)) |
197 | { |
171 | { |
198 | |
|
|
199 | /* message */ |
172 | /* message */ |
200 | if (tmp->nrof > 1) |
173 | new_draw_info_format (NDI_UNIQUE, 0, op, |
201 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumble to dust!", query_short_name (tmp)); |
174 | tmp->nrof > 1 ? "The %s crumble to dust!" : "The %s crumbles to dust!", |
202 | else |
175 | query_short_name (tmp)); |
203 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s crumbles to dust!", query_short_name (tmp)); |
|
|
204 | |
176 | |
205 | tmp->remove (); /* remove obj from players inv. */ |
177 | tmp->destroy (); |
206 | esrv_del_item (op->contr, tmp->count); /* notify client */ |
|
|
207 | tmp->destroy (); /* free object */ |
|
|
208 | } |
178 | } |
209 | |
179 | |
210 | if (tmp->inv) |
180 | if (tmp->inv) |
211 | follower_remove_similar_item (tmp, item); |
181 | follower_remove_similar_item (tmp, item); |
212 | } |
182 | } |
… | |
… | |
238 | * God gives an item to the player. |
208 | * God gives an item to the player. |
239 | */ |
209 | */ |
240 | static int |
210 | static int |
241 | god_gives_present (object *op, object *god, treasure *tr) |
211 | god_gives_present (object *op, object *god, treasure *tr) |
242 | { |
212 | { |
243 | object *tmp; |
|
|
244 | |
|
|
245 | if (!tr->item) |
213 | if (!tr->item) |
246 | return 0; |
214 | return 0; |
247 | |
215 | |
248 | if (follower_has_similar_item (op, &tr->item->clone)) |
216 | if (follower_has_similar_item (op, tr->item)) |
249 | return 0; |
217 | return 0; |
250 | |
218 | |
251 | tmp = arch_to_object (tr->item); |
219 | object *tmp = arch_to_object (tr->item); |
252 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp)); |
220 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s lets %s appear in your hands.", &god->name, query_short_name (tmp)); |
253 | tmp = insert_ob_in_ob (tmp, op); |
221 | op->insert (tmp); |
254 | if (op->type == PLAYER) |
|
|
255 | esrv_send_item (op, tmp); |
|
|
256 | |
222 | |
257 | return 1; |
223 | return 1; |
258 | } |
224 | } |
259 | |
225 | |
260 | /** |
226 | /** |
… | |
… | |
274 | return; |
240 | return; |
275 | |
241 | |
276 | /* hmm. what happend depends on pl's current god, level, etc */ |
242 | /* hmm. what happend depends on pl's current god, level, etc */ |
277 | if (!pl_god) |
243 | if (!pl_god) |
278 | { /*new convert */ |
244 | { /*new convert */ |
279 | become_follower (pl, &altar->other_arch->clone); |
245 | become_follower (pl, altar->other_arch); |
280 | return; |
246 | return; |
281 | |
|
|
282 | } |
247 | } |
283 | else if (!strcmp (&pl_god->name, altar->other_arch->clone.name)) |
248 | else if (pl_god->name == altar->other_arch->object::name) |
284 | { |
249 | { |
285 | /* pray at your gods altar */ |
250 | /* pray at your gods altar */ |
|
|
251 | /* this leads to very low levels of wis and pray to result in no doubling! */ |
286 | int bonus = (pl->stats.Wis + skill->level) / 10; |
252 | int bonus = (pl->stats.Wis + skill->level) / 10; |
287 | |
253 | |
288 | /* we can get neg grace up faster */ |
254 | /* we can get neg grace up faster */ |
289 | if (pl->stats.grace < 0) |
255 | if (pl->stats.grace < 0) |
290 | pl->stats.grace += (bonus > -1 * (pl->stats.grace / 10) ? bonus : -1 * (pl->stats.grace / 10)); |
256 | pl->stats.grace += (bonus > -1 * (pl->stats.grace / 10) ? bonus : -1 * (pl->stats.grace / 10)); |
|
|
257 | |
291 | /* we can super-charge grace to 2x max */ |
258 | /* we can super-charge grace to 2x max */ |
292 | if (pl->stats.grace < (2 * pl->stats.maxgrace)) |
259 | if (pl->stats.grace < 2 * pl->stats.maxgrace) |
293 | { |
|
|
294 | pl->stats.grace += bonus / 2; |
260 | pl->stats.grace += bonus / 2; |
295 | } |
261 | else |
296 | if (pl->stats.grace > (2 * pl->stats.maxgrace)) |
|
|
297 | { |
|
|
298 | pl->stats.grace = (2 * pl->stats.maxgrace); |
262 | pl->stats.grace = 2 * pl->stats.maxgrace; |
299 | } |
|
|
300 | |
263 | |
301 | /* Every once in a while, the god decides to checkup on their |
264 | /* Every once in a while, the god decides to checkup on their |
302 | * follower, and may intervene to help them out. |
265 | * follower, and may intervene to help them out. |
303 | */ |
266 | */ |
304 | bonus = MAX (1, bonus + MAX (pl->stats.luck, -3)); /* -- DAMN -- */ |
267 | bonus = max (1, bonus + max (pl->stats.luck, -3)); /* -- DAMN -- */ |
305 | |
268 | |
306 | if (((random_roll (0, 399, pl, PREFER_LOW)) - bonus) < 0) |
269 | if (((random_roll (0, 399, pl, PREFER_LOW)) - bonus) < 0) |
307 | god_intervention (pl, pl_god, skill); |
270 | god_intervention (pl, pl_god, skill); |
308 | |
|
|
309 | } |
271 | } |
310 | else |
272 | else |
311 | { /* praying to another god! */ |
273 | { /* praying to another god! */ |
312 | uint64 loss = 0; |
274 | uint64 loss = 0; |
313 | int angry = 1; |
275 | int angry = 1; |
… | |
… | |
317 | * points to the god of this altar (which we have |
279 | * points to the god of this altar (which we have |
318 | * already verified is non null). pl_god->other_arch |
280 | * already verified is non null). pl_god->other_arch |
319 | * is the opposing god - we need to verify that exists before |
281 | * is the opposing god - we need to verify that exists before |
320 | * using its values. |
282 | * using its values. |
321 | */ |
283 | */ |
322 | if (pl_god->other_arch && (altar->other_arch->name == pl_god->other_arch->name)) |
284 | if (pl_god->other_arch && (altar->other_arch->archname == pl_god->other_arch->archname)) |
323 | { |
285 | { |
324 | angry = 2; |
286 | angry = 2; |
325 | if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0) |
287 | if (random_roll (0, skill->level + 2, pl, PREFER_LOW) - 5 > 0) |
326 | { |
288 | { |
327 | object *tmp; |
289 | object *tmp; |
… | |
… | |
348 | |
310 | |
349 | /* May switch Gods, but its random chance based on our current level |
311 | /* May switch Gods, but its random chance based on our current level |
350 | * note it gets harder to swap gods the higher we get |
312 | * note it gets harder to swap gods the higher we get |
351 | */ |
313 | */ |
352 | if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) |
314 | if ((angry == 1) && !(random_roll (0, skill->level, pl, PREFER_LOW))) |
353 | { |
|
|
354 | become_follower (pl, &altar->other_arch->clone); |
315 | become_follower (pl, altar->other_arch); |
355 | } |
|
|
356 | else |
316 | else |
357 | { |
317 | { |
358 | /* toss this player off the altar. He can try again. */ |
318 | /* toss this player off the altar. He can try again. */ |
359 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar."); |
319 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, pl, "A divine force pushes you off the altar."); |
|
|
320 | pl->contr->fire_on = 0; |
|
|
321 | pl->speed_left = 1.f; |
360 | move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */ |
322 | move_player (pl, absdir (pl->facing + 4)); /* back him off the way he came. */ |
361 | } |
323 | } |
362 | } |
324 | } |
363 | } |
325 | } |
364 | |
326 | |
… | |
… | |
402 | object *item; |
364 | object *item; |
403 | |
365 | |
404 | if (!tr->item) |
366 | if (!tr->item) |
405 | continue; |
367 | continue; |
406 | |
368 | |
407 | item = &tr->item->clone; |
369 | item = tr->item; |
408 | |
370 | |
409 | /* Basically, see if the matching spell is granted by this god. */ |
371 | /* Basically, see if the matching spell is granted by this god. */ |
410 | |
372 | |
411 | if (tr->item->clone.type == SPELL && tr->item->clone.name == tmp->name) |
373 | if (tr->item->type == SPELL && tr->item->object::name == tmp->name) |
412 | { |
374 | { |
413 | remove = 0; |
375 | remove = 0; |
414 | break; |
376 | break; |
415 | } |
377 | } |
416 | } |
378 | } |
|
|
379 | |
417 | if (remove) |
380 | if (remove) |
418 | { |
381 | do_forget_spell (op, tmp->name); |
419 | /* just do the work of removing the spell ourselves - we already |
|
|
420 | * know that the player knows the spell |
|
|
421 | */ |
|
|
422 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &tmp->name); |
|
|
423 | player_unready_range_ob (op->contr, tmp); |
|
|
424 | tmp->destroy (); |
|
|
425 | } |
|
|
426 | |
|
|
427 | } |
382 | } |
428 | } |
383 | } |
429 | |
384 | |
430 | /** |
385 | /** |
431 | * This function is called whenever a player has |
386 | * This function is called whenever a player has |
… | |
… | |
439 | object *old_god = NULL; /* old god */ |
394 | object *old_god = NULL; /* old god */ |
440 | treasure *tr; |
395 | treasure *tr; |
441 | object *item, *skop, *next; |
396 | object *item, *skop, *next; |
442 | int i, sk_applied, undeadified = 0; /* Turns to true if changing god can changes the undead status of the player. */ |
397 | int i, sk_applied, undeadified = 0; /* Turns to true if changing god can changes the undead status of the player. */ |
443 | |
398 | |
444 | |
|
|
445 | old_god = find_god (determine_god (op)); |
399 | old_god = find_god (determine_god (op)); |
446 | |
400 | |
447 | /* take away any special god-characteristic items. */ |
401 | /* take away any special god-characteristic items. */ |
448 | for (item = op->inv; item != NULL; item = next) |
402 | for (item = op->inv; item; item = next) |
449 | { |
403 | { |
450 | next = item->below; |
404 | next = item->below; |
|
|
405 | |
451 | // remove all invisible startequip items which are not skill, exp or force |
406 | // remove all invisible startequip items which are not skill, exp or force |
452 | if (QUERY_FLAG (item, FLAG_STARTEQUIP) && item->invisible && |
407 | if (QUERY_FLAG (item, FLAG_STARTEQUIP) && item->invisible && |
453 | (item->type != SKILL) && (item->type != FORCE)) |
408 | (item->type != SKILL) && (item->type != FORCE)) |
454 | { |
409 | { |
455 | |
|
|
456 | if (item->type == SPELL) |
410 | if (item->type == SPELL) |
|
|
411 | { |
457 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name); |
412 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You lose knowledge of %s.", &item->name); |
|
|
413 | esrv_remove_spell (op->contr, item); |
|
|
414 | } |
458 | |
415 | |
459 | player_unready_range_ob (op->contr, item); |
416 | player_unready_range_ob (op->contr, item); |
460 | item->destroy (); |
417 | item->destroy (); |
461 | } |
418 | } |
462 | } |
419 | } |
463 | |
420 | |
464 | /* remove any godgiven items from the old god */ |
421 | /* remove any godgiven items from the old god */ |
465 | if (old_god) |
422 | if (old_god) |
466 | for (tr = old_god->randomitems->items; tr; tr = tr->next) |
423 | for (tr = old_god->randomitems->items; tr; tr = tr->next) |
467 | if (tr->item && QUERY_FLAG (&tr->item->clone, FLAG_STARTEQUIP)) |
424 | if (tr->item && QUERY_FLAG (tr->item, FLAG_STARTEQUIP)) |
468 | follower_remove_similar_item (op, &tr->item->clone); |
425 | follower_remove_similar_item (op, tr->item); |
469 | |
426 | |
470 | if (!op || !new_god) |
427 | if (!op || !new_god) |
471 | return; |
428 | return; |
472 | |
429 | |
473 | if (op->race && new_god->slaying && strstr (op->race, new_god->slaying)) |
430 | if (new_god->slaying && op->race.contains (new_god->slaying)) |
474 | { |
431 | { |
475 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); |
432 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "Fool! %s detests your kind!", &new_god->name); |
476 | |
433 | |
477 | if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) |
434 | if (random_roll (0, op->level - 1, op, PREFER_LOW) - 5 > 0) |
478 | { |
435 | { |
… | |
… | |
481 | cast_magic_storm (op, tmp, new_god->level + 10); |
438 | cast_magic_storm (op, tmp, new_god->level + 10); |
482 | } |
439 | } |
483 | |
440 | |
484 | return; |
441 | return; |
485 | } |
442 | } |
486 | |
|
|
487 | |
443 | |
488 | /* give the player any special god-characteristic-items. */ |
444 | /* give the player any special god-characteristic-items. */ |
489 | for (tr = new_god->randomitems->items; tr; tr = tr->next) |
445 | for (tr = new_god->randomitems->items; tr; tr = tr->next) |
490 | { |
446 | { |
491 | if (tr->item && tr->item->clone.invisible && tr->item->clone.type != SPELLBOOK |
447 | if (tr->item && tr->item->invisible && tr->item->type != SPELLBOOK |
492 | && tr->item->clone.type != BOOK && tr->item->clone.type != SPELL) |
448 | && tr->item->type != BOOK && tr->item->type != SPELL) |
493 | god_gives_present (op, new_god, tr); |
449 | god_gives_present (op, new_god, tr); |
494 | } |
450 | } |
495 | |
451 | |
496 | |
|
|
497 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); |
452 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "You become a follower of %s!", &new_god->name); |
498 | |
453 | |
499 | for (skop = op->inv; skop != NULL; skop = skop->below) |
454 | for (skop = op->inv; skop; skop = skop->below) |
500 | if (skop->type == SKILL && skop->subtype == SK_PRAYING) |
455 | if (skop->type == SKILL && skop->subtype == SK_PRAYING) |
501 | break; |
456 | break; |
502 | |
457 | |
503 | /* Player has no skill - give them the skill */ |
458 | /* Player has no skill - give them the skill */ |
504 | if (!skop) |
459 | if (!skop) |
505 | { |
|
|
506 | /* The arhetype should always be defined - if we crash here because it doesn't, |
460 | /* The archetype should always be defined - if we crash here because it doesn't, |
507 | * things are really messed up anyways. |
461 | * things are really messed up anyways. |
508 | */ |
462 | */ |
509 | skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->clone.skill); |
463 | skop = give_skill_by_name (op, get_archetype_by_type_subtype (SKILL, SK_PRAYING)->skill); |
510 | link_player_skills (op); |
|
|
511 | } |
|
|
512 | |
464 | |
513 | sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */ |
465 | sk_applied = QUERY_FLAG (skop, FLAG_APPLIED); /* save skill status */ |
514 | |
466 | |
515 | /* Clear the "undead" status. We also need to force a call to change_abil, |
467 | /* Clear the "undead" status. We also need to force a call to change_abil, |
516 | * so I set undeadified for that. |
468 | * so I set undeadified for that. |
517 | * - gros, 21th July 2006. |
469 | * - gros, 21th July 2006. |
518 | */ |
470 | */ |
519 | if ((old_god) && (QUERY_FLAG (old_god, FLAG_UNDEAD))) |
471 | if (old_god && QUERY_FLAG (old_god, FLAG_UNDEAD)) |
520 | { |
472 | { |
521 | CLEAR_FLAG (skop, FLAG_UNDEAD); |
473 | CLEAR_FLAG (skop, FLAG_UNDEAD); |
522 | undeadified = 1; |
474 | undeadified = 1; |
523 | } |
475 | } |
524 | |
476 | |
525 | if (skop->title) |
477 | if (skop->title) |
526 | { /* get rid of old god */ |
478 | { |
|
|
479 | /* get rid of old god */ |
527 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s's blessing is withdrawn from you.", &skop->title); |
480 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s's blessing is withdrawn from you.", &skop->title); |
|
|
481 | |
528 | /* The point of this is to really show what abilities the player just lost */ |
482 | /* The point of this is to really show what abilities the player just lost */ |
529 | if (sk_applied || undeadified) |
483 | if (sk_applied || undeadified) |
530 | { |
484 | { |
531 | |
|
|
532 | CLEAR_FLAG (skop, FLAG_APPLIED); |
485 | CLEAR_FLAG (skop, FLAG_APPLIED); |
533 | (void) change_abil (op, skop); |
486 | change_abil (op, skop); |
534 | } |
487 | } |
535 | } |
488 | } |
536 | |
489 | |
537 | /* now change to the new gods attributes to exp_obj */ |
490 | /* now change to the new gods attributes to exp_obj */ |
538 | skop->title = new_god->name; |
491 | skop->title = new_god->name; |
… | |
… | |
573 | * This also can happen for monks which cannot use weapons. In this case |
526 | * This also can happen for monks which cannot use weapons. In this case |
574 | * do not allow to use weapons even if the god otherwise would allow it. |
527 | * do not allow to use weapons even if the god otherwise would allow it. |
575 | */ |
528 | */ |
576 | if (!present_in_ob_by_name (FORCE, "no weapon force", op)) |
529 | if (!present_in_ob_by_name (FORCE, "no weapon force", op)) |
577 | update_priest_flag (new_god, skop, FLAG_USE_WEAPON); |
530 | update_priest_flag (new_god, skop, FLAG_USE_WEAPON); |
|
|
531 | |
578 | update_priest_flag (new_god, skop, FLAG_USE_ARMOUR); |
532 | update_priest_flag (new_god, skop, FLAG_USE_ARMOUR); |
579 | |
533 | |
580 | if (worship_forbids_use (op, skop, FLAG_USE_WEAPON, "weapons")) |
534 | if (worship_forbids_use (op, skop, FLAG_USE_WEAPON, "weapons")) |
581 | stop_using_item (op, WEAPON, 2); |
535 | stop_using_item (op, WEAPON, 2); |
582 | |
536 | |
… | |
… | |
608 | */ |
562 | */ |
609 | |
563 | |
610 | int |
564 | int |
611 | worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) |
565 | worship_forbids_use (object *op, object *exp_obj, uint32 flag, const char *string) |
612 | { |
566 | { |
613 | |
|
|
614 | if (QUERY_FLAG (&op->arch->clone, flag)) |
567 | if (QUERY_FLAG (op->arch, flag)) |
615 | if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag)) |
568 | if (QUERY_FLAG (op, flag) != QUERY_FLAG (exp_obj, flag)) |
616 | { |
569 | { |
617 | update_priest_flag (exp_obj, op, flag); |
570 | update_priest_flag (exp_obj, op, flag); |
618 | if (QUERY_FLAG (op, flag)) |
571 | if (QUERY_FLAG (op, flag)) |
619 | new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string); |
572 | new_draw_info_format (NDI_UNIQUE, 0, op, "You may use %s again.", string); |
… | |
… | |
621 | { |
574 | { |
622 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are forbidden to use %s.", string); |
575 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are forbidden to use %s.", string); |
623 | return 1; |
576 | return 1; |
624 | } |
577 | } |
625 | } |
578 | } |
|
|
579 | |
626 | return 0; |
580 | return 0; |
627 | } |
581 | } |
628 | |
582 | |
629 | /** |
583 | /** |
630 | * Unapplies up to number worth of items of type |
584 | * Unapplies up to number worth of items of type |
… | |
… | |
667 | /* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/ |
621 | /* if (!(QUERY_FLAG(&(exp_ob->arch->clone),flag)))*/ |
668 | CLEAR_FLAG (exp_ob, flag); |
622 | CLEAR_FLAG (exp_ob, flag); |
669 | }; |
623 | }; |
670 | } |
624 | } |
671 | |
625 | |
672 | |
|
|
673 | |
|
|
674 | archetype * |
626 | archetype * |
675 | determine_holy_arch (object *god, const char *type) |
627 | determine_holy_arch (object *god, shstr_cmp type) |
676 | { |
628 | { |
677 | treasure *tr; |
629 | treasure *tr; |
678 | |
630 | |
679 | if (!god || !god->randomitems) |
631 | if (!god || !god->randomitems) |
680 | { |
632 | { |
681 | LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n"); |
633 | LOG (llevError, "BUG: determine_holy_arch(): no god or god without " "randomitems\n"); |
682 | return NULL; |
634 | return 0; |
683 | } |
635 | } |
684 | |
636 | |
685 | for (tr = god->randomitems->items; tr; tr = tr->next) |
637 | for (tr = god->randomitems->items; tr; tr = tr->next) |
686 | { |
638 | { |
687 | if (!tr->item) |
639 | if (!tr->item) |
688 | continue; |
640 | continue; |
689 | |
641 | |
690 | object *item = &tr->item->clone; |
642 | object *item = tr->item; |
691 | |
643 | |
692 | if (item->type == BOOK && item->invisible && strcmp (item->name, type) == 0) |
644 | if (item->type == BOOK && item->invisible && item->name == type) |
693 | return item->other_arch; |
645 | return item->other_arch; |
694 | } |
646 | } |
|
|
647 | |
695 | return NULL; |
648 | return 0; |
696 | } |
649 | } |
697 | |
650 | |
698 | /** |
651 | /** |
699 | * God helps player by removing curse and/or damnation. |
652 | * God helps player by removing curse and/or damnation. |
700 | */ |
653 | */ |
701 | static int |
654 | static int |
702 | god_removes_curse (object *op, int remove_damnation) |
655 | god_removes_curse (object *op, int remove_damnation) |
703 | { |
656 | { |
704 | object *tmp; |
|
|
705 | int success = 0; |
657 | int success = 0; |
706 | |
658 | |
707 | for (tmp = op->inv; tmp; tmp = tmp->below) |
659 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
708 | { |
660 | { |
709 | if (tmp->invisible) |
661 | if (tmp->invisible) |
710 | continue; |
662 | continue; |
|
|
663 | |
711 | if (QUERY_FLAG (tmp, FLAG_DAMNED) && !remove_damnation) |
664 | if (QUERY_FLAG (tmp, FLAG_DAMNED) && !remove_damnation) |
712 | continue; |
665 | continue; |
|
|
666 | |
713 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
667 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
714 | { |
668 | { |
715 | success = 1; |
669 | success = 1; |
716 | CLEAR_FLAG (tmp, FLAG_DAMNED); |
670 | CLEAR_FLAG (tmp, FLAG_DAMNED); |
717 | CLEAR_FLAG (tmp, FLAG_CURSED); |
671 | CLEAR_FLAG (tmp, FLAG_CURSED); |
718 | CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED); |
672 | CLEAR_FLAG (tmp, FLAG_KNOWN_CURSED); |
719 | if (op->type == PLAYER) |
673 | |
|
|
674 | if (object *pl = tmp->visible_to ()) |
720 | esrv_send_item (op, tmp); |
675 | esrv_update_item (UPD_FLAGS, pl, tmp); |
721 | } |
676 | } |
722 | } |
677 | } |
723 | |
678 | |
724 | if (success) |
679 | if (success) |
725 | new_draw_info (NDI_UNIQUE, 0, op, "You feel like someone is helping you."); |
680 | new_draw_info (NDI_UNIQUE, 0, op, "You feel like someone is helping you."); |
|
|
681 | |
726 | return success; |
682 | return success; |
727 | } |
683 | } |
728 | |
684 | |
729 | static int |
685 | static int |
730 | follower_level_to_enchantments (int level, int difficulty) |
686 | follower_level_to_enchantments (int level, int difficulty) |
… | |
… | |
735 | return 0; |
691 | return 0; |
736 | } |
692 | } |
737 | |
693 | |
738 | if (level <= 20) |
694 | if (level <= 20) |
739 | return level / difficulty; |
695 | return level / difficulty; |
|
|
696 | |
740 | if (level <= 40) |
697 | if (level <= 40) |
741 | return (20 + (level - 20) / 2) / difficulty; |
698 | return (20 + (level - 20) / 2) / difficulty; |
742 | |
699 | |
743 | return (30 + (level - 40) / 4) / difficulty; |
700 | return (30 + (level - 40) / 4) / difficulty; |
744 | } |
701 | } |
… | |
… | |
750 | * attacktype, slaying and such. |
707 | * attacktype, slaying and such. |
751 | */ |
708 | */ |
752 | static int |
709 | static int |
753 | god_enchants_weapon (object *op, object *god, object *tr, object *skill) |
710 | god_enchants_weapon (object *op, object *god, object *tr, object *skill) |
754 | { |
711 | { |
755 | char buf[MAX_BUF]; |
|
|
756 | object *weapon; |
712 | object *weapon; |
757 | uint32 attacktype; |
713 | uint32 attacktype; |
758 | int tmp; |
714 | int tmp; |
759 | |
715 | |
760 | for (weapon = op->inv; weapon; weapon = weapon->below) |
716 | for (weapon = op->inv; weapon; weapon = weapon->below) |
761 | if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) |
717 | if ((weapon->type == WEAPON || weapon->type == BOW) && QUERY_FLAG (weapon, FLAG_APPLIED)) |
762 | break; |
718 | break; |
763 | |
719 | |
764 | if (weapon == NULL || god_examines_item (god, weapon) <= 0) |
720 | if (!weapon || god_examines_item (god, weapon) <= 0) |
765 | return 0; |
721 | return 0; |
766 | |
722 | |
767 | /* First give it a title, so other gods won't touch it */ |
723 | /* First give it a title, so other gods won't touch it */ |
768 | if (!weapon->title) |
724 | if (!weapon->title) |
769 | { |
725 | { |
770 | sprintf (buf, "of %s", &god->name); |
726 | weapon->title = format ("of %s", &god->name); |
771 | weapon->title = buf; |
727 | |
772 | if (op->type == PLAYER) |
728 | if (object *pl = weapon->visible_to ()) |
773 | esrv_update_item (UPD_NAME, op, weapon); |
729 | esrv_update_item (UPD_NAME, pl, weapon); |
|
|
730 | |
774 | new_draw_info (NDI_UNIQUE, 0, op, "Your weapon quivers as if struck!"); |
731 | new_draw_info (NDI_UNIQUE, 0, op, "Your weapon quivers as if struck!"); |
775 | } |
732 | } |
776 | |
733 | |
777 | /* Allow the weapon to slay enemies */ |
734 | /* Allow the weapon to slay enemies */ |
778 | if (!weapon->slaying && god->slaying) |
735 | if (!weapon->slaying && god->slaying) |
… | |
… | |
795 | tmp = follower_level_to_enchantments (skill->level, tr->level); |
752 | tmp = follower_level_to_enchantments (skill->level, tr->level); |
796 | if (weapon->magic < tmp) |
753 | if (weapon->magic < tmp) |
797 | { |
754 | { |
798 | new_draw_info (NDI_UNIQUE, 0, op, "A phosphorescent glow envelops your weapon!"); |
755 | new_draw_info (NDI_UNIQUE, 0, op, "A phosphorescent glow envelops your weapon!"); |
799 | weapon->magic++; |
756 | weapon->magic++; |
800 | if (op->type == PLAYER) |
757 | |
|
|
758 | if (object *pl = weapon->visible_to ()) |
801 | esrv_update_item (UPD_NAME, op, weapon); |
759 | esrv_update_item (UPD_NAME, pl, weapon); |
|
|
760 | |
802 | return 1; |
761 | return 1; |
803 | } |
762 | } |
804 | |
763 | |
805 | return 0; |
764 | return 0; |
806 | } |
765 | } |
807 | |
|
|
808 | |
766 | |
809 | /** |
767 | /** |
810 | * Every once in a while the god will intervene to help the worshiper. |
768 | * Every once in a while the god will intervene to help the worshiper. |
811 | * Later, this fctn can be used to supply quests, etc for the |
769 | * Later, this fctn can be used to supply quests, etc for the |
812 | * priest. -b.t. |
770 | * priest. -b.t. |
813 | * called from pray_at_altar() currently. |
771 | * called from pray_at_altar() currently. |
814 | */ |
772 | */ |
815 | |
|
|
816 | void |
773 | void |
817 | god_intervention (object *op, object *god, object *skill) |
774 | god_intervention (object *op, object *god, object *skill) |
818 | { |
775 | { |
819 | treasure *tr; |
776 | treasure *tr; |
820 | |
777 | |
… | |
… | |
828 | |
785 | |
829 | /* lets do some checks of whether we are kosher with our god */ |
786 | /* lets do some checks of whether we are kosher with our god */ |
830 | if (god_examines_priest (op, god) < 0) |
787 | if (god_examines_priest (op, god) < 0) |
831 | return; |
788 | return; |
832 | |
789 | |
|
|
790 | op->play_sound (sound_find ("god_intervention")); |
833 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!"); |
791 | new_draw_info (NDI_UNIQUE, 0, op, "You feel a holy presence!"); |
834 | |
792 | |
835 | for (tr = god->randomitems->items; tr; tr = tr->next) |
793 | for (tr = god->randomitems->items; tr; tr = tr->next) |
836 | { |
794 | { |
837 | object *item; |
795 | object *item; |
… | |
… | |
845 | treasurelist *tl = treasurelist::find (tr->name); |
803 | treasurelist *tl = treasurelist::find (tr->name); |
846 | |
804 | |
847 | if (tl == NULL) |
805 | if (tl == NULL) |
848 | continue; |
806 | continue; |
849 | |
807 | |
850 | new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your " "eyes. You catch it before it falls to the ground."); |
808 | new_draw_info (NDI_UNIQUE, 0, op, "Something appears before your eyes. You catch it before it falls to the ground."); |
851 | |
809 | |
852 | create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD | GT_UPDATE_INV, skill->level, 0); |
810 | create_treasure (tl, op, GT_STARTEQUIP | GT_ONLY_GOOD, skill->level, 0); |
853 | return; |
811 | return; |
854 | } |
812 | } |
855 | |
813 | |
856 | if (!tr->item) |
814 | if (!tr->item) |
857 | continue; |
815 | continue; |
858 | |
816 | |
859 | item = &tr->item->clone; |
817 | item = tr->item; |
860 | |
818 | |
861 | /* Grace limit */ |
819 | /* Grace limit */ |
862 | if (item->type == BOOK && item->invisible && strcmp (item->name, "grace limit") == 0) |
820 | if (item->type == BOOK && item->invisible && item->name == shstr_grace_limit) |
863 | { |
821 | { |
864 | if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace) |
822 | if (op->stats.grace < item->stats.grace || op->stats.grace < op->stats.maxgrace) |
865 | { |
823 | { |
866 | object *tmp; |
|
|
867 | |
|
|
868 | /* Follower lacks the required grace for the following |
824 | /* Follower lacks the required grace for the following |
869 | * treasure list items. */ |
825 | * treasure list items. */ |
870 | |
826 | |
871 | tmp = get_archetype (HOLY_POSSESSION); |
827 | object *tmp = get_archetype (HOLY_POSSESSION); |
872 | cast_change_ability (op, op, tmp, 0, 1); |
828 | cast_change_ability (op, op, tmp, 0, 1); |
873 | tmp->destroy (); |
829 | tmp->destroy (); |
874 | return; |
830 | return; |
875 | } |
831 | } |
|
|
832 | |
876 | continue; |
833 | continue; |
877 | } |
834 | } |
878 | |
835 | |
879 | /* Restore grace */ |
836 | /* Restore grace */ |
880 | if (item->type == BOOK && item->invisible && strcmp (item->name, "restore grace") == 0) |
837 | if (item->type == BOOK && item->invisible && item->name == shstr_restore_grace) |
881 | { |
838 | { |
882 | if (op->stats.grace >= 0) |
839 | if (op->stats.grace >= 0) |
883 | continue; |
840 | continue; |
|
|
841 | |
884 | op->stats.grace = random_roll (0, 9, op, PREFER_HIGH); |
842 | op->stats.grace = random_roll (0, 9, op, PREFER_HIGH); |
885 | new_draw_info (NDI_UNIQUE, 0, op, "You are returned to a state of grace."); |
843 | new_draw_info (NDI_UNIQUE, 0, op, "You are returned to a state of grace."); |
886 | return; |
844 | return; |
887 | } |
845 | } |
888 | |
846 | |
889 | /* Heal damage */ |
847 | /* Heal damage */ |
890 | if (item->type == BOOK && item->invisible && strcmp (item->name, "restore hitpoints") == 0) |
848 | if (item->type == BOOK && item->invisible && strcmp (item->name, "restore hitpoints") == 0) |
891 | { |
849 | { |
892 | if (op->stats.hp >= op->stats.maxhp) |
850 | if (op->stats.hp >= op->stats.maxhp) |
893 | continue; |
851 | continue; |
|
|
852 | |
894 | new_draw_info (NDI_UNIQUE, 0, op, "A white light surrounds and heals you!"); |
853 | new_draw_info (NDI_UNIQUE, 0, op, "A white light surrounds and heals you!"); |
895 | op->stats.hp = op->stats.maxhp; |
854 | op->stats.hp = op->stats.maxhp; |
896 | return; |
855 | return; |
897 | } |
856 | } |
898 | |
857 | |
… | |
… | |
904 | /* Restore to 50 .. 100%, if sp < 50% */ |
863 | /* Restore to 50 .. 100%, if sp < 50% */ |
905 | int new_sp = (int) (random_roll (1000, 1999, op, PREFER_HIGH) / 2000.0 * max); |
864 | int new_sp = (int) (random_roll (1000, 1999, op, PREFER_HIGH) / 2000.0 * max); |
906 | |
865 | |
907 | if (op->stats.sp >= max / 2) |
866 | if (op->stats.sp >= max / 2) |
908 | continue; |
867 | continue; |
|
|
868 | |
909 | new_draw_info (NDI_UNIQUE, 0, op, "A blue lightning strikes " "your head but doesn't hurt you!"); |
869 | new_draw_info (NDI_UNIQUE, 0, op, "A blue lightning strikes your head but doesn't hurt you!"); |
910 | op->stats.sp = new_sp; |
870 | op->stats.sp = new_sp; |
911 | } |
871 | } |
912 | |
872 | |
913 | /* Various heal spells */ |
873 | /* Various heal spells */ |
914 | if (item->type == BOOK && item->invisible && strcmp (item->name, "heal spell") == 0) |
874 | if (item->type == BOOK && item->invisible && strcmp (item->name, "heal spell") == 0) |
915 | { |
875 | { |
916 | object *tmp; |
|
|
917 | int success; |
|
|
918 | |
|
|
919 | tmp = get_archetype_by_object_name (item->slaying); |
876 | object *tmp = archetype::get (item->slaying); |
920 | |
|
|
921 | success = cast_heal (op, op, tmp, 0); |
877 | int success = cast_heal (op, op, tmp, 0); |
922 | tmp->destroy (); |
878 | tmp->destroy (); |
|
|
879 | |
923 | if (success) |
880 | if (success) |
924 | return; |
881 | return; |
925 | else |
882 | else |
926 | continue; |
883 | continue; |
927 | } |
884 | } |
… | |
… | |
954 | if ((at = archetype::find (ARCH_DEPLETION)) == NULL) |
911 | if ((at = archetype::find (ARCH_DEPLETION)) == NULL) |
955 | { |
912 | { |
956 | LOG (llevError, "Could not find archetype depletion.\n"); |
913 | LOG (llevError, "Could not find archetype depletion.\n"); |
957 | continue; |
914 | continue; |
958 | } |
915 | } |
|
|
916 | |
959 | depl = present_arch_in_ob (at, op); |
917 | depl = present_arch_in_ob (at, op); |
960 | |
918 | |
961 | if (depl == NULL) |
919 | if (depl == NULL) |
962 | continue; |
920 | continue; |
963 | |
921 | |
… | |
… | |
973 | } |
931 | } |
974 | |
932 | |
975 | /* Voices */ |
933 | /* Voices */ |
976 | if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0) |
934 | if (item->type == BOOK && item->invisible && strcmp (item->name, "voice_behind") == 0) |
977 | { |
935 | { |
978 | new_draw_info (NDI_UNIQUE, 0, op, "You hear a voice from behind you, but you don't dare to " "turn around:"); |
936 | new_draw_info (NDI_UNIQUE, 0, op, "You hear a voice from behind you, but you don't dare to turn around:"); |
979 | new_draw_info (NDI_WHITE, 0, op, item->msg); |
937 | new_draw_info (NDI_WHITE, 0, op, item->msg); |
980 | return; |
938 | return; |
981 | } |
939 | } |
982 | |
940 | |
983 | /* Messages */ |
941 | /* Messages */ |
… | |
… | |
1034 | { |
992 | { |
1035 | int reaction = 1; |
993 | int reaction = 1; |
1036 | object *item = NULL, *skop; |
994 | object *item = NULL, *skop; |
1037 | |
995 | |
1038 | for (item = op->inv; item; item = item->below) |
996 | for (item = op->inv; item; item = item->below) |
1039 | { |
|
|
1040 | if (QUERY_FLAG (item, FLAG_APPLIED)) |
997 | if (QUERY_FLAG (item, FLAG_APPLIED)) |
1041 | { |
|
|
1042 | reaction += god_examines_item (god, item) * (item->magic ? abs (item->magic) : 1); |
998 | reaction += god_examines_item (god, item) * (item->magic ? abs (item->magic) : 1); |
1043 | } |
|
|
1044 | } |
|
|
1045 | |
999 | |
1046 | /* well, well. Looks like we screwed up. Time for god's revenge */ |
1000 | /* well, well. Looks like we screwed up. Time for god's revenge */ |
1047 | if (reaction < 0) |
1001 | if (reaction < 0) |
1048 | { |
1002 | { |
1049 | int loss = 10000000; |
1003 | int loss = 10000000; |
1050 | int angry = abs (reaction); |
1004 | int angry = abs (reaction); |
1051 | |
1005 | |
1052 | for (skop = op->inv; skop != NULL; skop = skop->below) |
1006 | for (skop = op->inv; skop; skop = skop->below) |
1053 | if (skop->type == SKILL && skop->subtype == SK_PRAYING) |
1007 | if (skop->type == SKILL && skop->subtype == SK_PRAYING) |
1054 | break; |
1008 | break; |
1055 | |
1009 | |
1056 | if (skop) |
1010 | if (skop) |
1057 | loss = (int) (0.05 * (float) skop->stats.exp); |
1011 | loss = 0.05f * skop->stats.exp; |
|
|
1012 | |
1058 | change_exp (op, -random_roll (0, loss * angry - 1, op, PREFER_LOW), skop ? &skop->skill : "none", SK_SUBTRACT_SKILL_EXP); |
1013 | change_exp (op, -random_roll (0, loss * angry - 1, op, PREFER_LOW), skop ? &skop->skill : "none", SK_SUBTRACT_SKILL_EXP); |
|
|
1014 | |
1059 | if (random_roll (0, angry, op, PREFER_LOW)) |
1015 | if (random_roll (0, angry, op, PREFER_LOW)) |
1060 | { |
1016 | { |
1061 | object *tmp = get_archetype (LOOSE_MANA); |
1017 | object *tmp = get_archetype (LOOSE_MANA); |
1062 | |
1018 | |
1063 | cast_magic_storm (op, tmp, op->level + (angry * 3)); |
1019 | cast_magic_storm (op, tmp, op->level + (angry * 3)); |
1064 | } |
1020 | } |
|
|
1021 | |
1065 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "%s becomes angry and punishes you!", &god->name); |
1022 | new_draw_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, "%s becomes angry and punishes you!", &god->name); |
1066 | } |
1023 | } |
|
|
1024 | |
1067 | return reaction; |
1025 | return reaction; |
1068 | } |
1026 | } |
1069 | |
1027 | |
1070 | /** |
1028 | /** |
1071 | * God checks item the player is using. |
1029 | * God checks item the player is using. |
1072 | * Return either -1 (bad), 0 (neutral) or |
1030 | * Return either -1 (bad), 0 (neutral) or |
1073 | * 1 (item is ok). If you are using the item of an enemy |
1031 | * 1 (item is ok). If you are using the item of an enemy |
1074 | * god, it can be bad...-b.t. |
1032 | * god, it can be bad...-b.t. |
1075 | */ |
1033 | */ |
1076 | |
|
|
1077 | int |
1034 | int |
1078 | god_examines_item (object *god, object *item) |
1035 | god_examines_item (object *god, object *item) |
1079 | { |
1036 | { |
1080 | char buf[MAX_BUF]; |
1037 | char buf[MAX_BUF]; |
1081 | |
1038 | |
… | |
… | |
1084 | |
1041 | |
1085 | if (!item->title) |
1042 | if (!item->title) |
1086 | return 1; /* unclaimed item are ok */ |
1043 | return 1; /* unclaimed item are ok */ |
1087 | |
1044 | |
1088 | sprintf (buf, "of %s", &god->name); |
1045 | sprintf (buf, "of %s", &god->name); |
1089 | if (!strcmp (item->title, buf)) |
1046 | if (!strcmp (&item->title, buf)) |
1090 | return 1; /* belongs to that God */ |
1047 | return 1; /* belongs to that God */ |
1091 | |
1048 | |
1092 | if (god->title) |
1049 | if (god->title) |
1093 | { /* check if we have any enemy blessed item */ |
1050 | { /* check if we have any enemy blessed item */ |
1094 | sprintf (buf, "of %s", &god->title); |
1051 | sprintf (buf, "of %s", &god->title); |
1095 | if (!strcmp (item->title, buf)) |
1052 | if (!strcmp (&item->title, buf)) |
1096 | { |
1053 | { |
1097 | if (item->env) |
1054 | if (item->env) |
1098 | { |
1055 | { |
1099 | char buf[MAX_BUF]; |
1056 | char buf[MAX_BUF]; |
1100 | |
1057 | |
1101 | sprintf (buf, "Heretic! You are using %s!", query_name (item)); |
1058 | sprintf (buf, "Heretic! You are using %s!", query_name (item)); |
1102 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, item->env, buf); |
1059 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, item->env, buf); |
1103 | } |
1060 | } |
|
|
1061 | |
1104 | return -1; |
1062 | return -1; |
1105 | } |
1063 | } |
1106 | } |
1064 | } |
1107 | |
1065 | |
1108 | return 0; /* item is sacred to a non-enemy god/or is otherwise magical */ |
1066 | return 0; /* item is sacred to a non-enemy god/or is otherwise magical */ |
… | |
… | |
1110 | |
1068 | |
1111 | /** |
1069 | /** |
1112 | * Returns priest's god's id. |
1070 | * Returns priest's god's id. |
1113 | * Straight calls lookup_god_by_name |
1071 | * Straight calls lookup_god_by_name |
1114 | */ |
1072 | */ |
1115 | |
|
|
1116 | int |
1073 | int |
1117 | get_god (object *priest) |
1074 | get_god (object *priest) |
1118 | { |
1075 | { |
1119 | int godnr = lookup_god_by_name (determine_god (priest)); |
1076 | return lookup_god_by_name (determine_god (priest)); |
1120 | |
|
|
1121 | return godnr; |
|
|
1122 | } |
|
|
1123 | |
|
|
1124 | /** |
|
|
1125 | * Returns a string that is the name of the god that should be natively worshipped by a |
|
|
1126 | * creature of who has race *race |
|
|
1127 | * if we can't find a god that is appropriate, we return NULL |
|
|
1128 | */ |
|
|
1129 | const char * |
|
|
1130 | get_god_for_race (const char *race) |
|
|
1131 | { |
|
|
1132 | godlink *gl = first_god; |
|
|
1133 | const char *godname = NULL; |
|
|
1134 | |
|
|
1135 | if (race == NULL) |
|
|
1136 | return NULL; |
|
|
1137 | while (gl) |
|
|
1138 | { |
|
|
1139 | if (!strcasecmp (gl->arch->clone.race, race)) |
|
|
1140 | { |
|
|
1141 | godname = gl->name; |
|
|
1142 | break; |
|
|
1143 | } |
|
|
1144 | gl = gl->next; |
|
|
1145 | } |
|
|
1146 | return godname; |
|
|
1147 | } |
1077 | } |
1148 | |
1078 | |
1149 | /** |
1079 | /** |
1150 | * Changes the attributes of cone, smite, and ball spells as needed by the code. |
1080 | * Changes the attributes of cone, smite, and ball spells as needed by the code. |
1151 | * Returns false if there was no race to assign to the slaying field of the spell, but |
1081 | * Returns false if there was no race to assign to the slaying field of the spell, but |