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