… | |
… | |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra 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 | * Deliantra 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 3 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, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include <global.h> |
25 | #include <global.h> |
… | |
… | |
71 | if (!(random_roll (0, 3, op, PREFER_HIGH))) |
72 | if (!(random_roll (0, 3, op, PREFER_HIGH))) |
72 | { |
73 | { |
73 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand)); |
74 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand)); |
74 | op->play_sound (sound_find ("ob_explode")); |
75 | op->play_sound (sound_find ("ob_explode")); |
75 | wand->destroy (); |
76 | wand->destroy (); |
76 | tmp = get_archetype ("fireball"); |
77 | tmp = get_archetype (shstr_fireball); |
77 | tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; |
78 | tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; |
78 | |
79 | |
79 | if (!tmp->stats.dam) |
80 | if (!tmp->stats.dam) |
80 | tmp->stats.dam = 1; |
81 | tmp->stats.dam = 1; |
81 | |
82 | |
… | |
… | |
564 | |
565 | |
565 | int |
566 | int |
566 | perceive_self (object *op) |
567 | perceive_self (object *op) |
567 | { |
568 | { |
568 | const char *cp = describe_item (op, op); |
569 | const char *cp = describe_item (op, op); |
569 | archetype *at = archetype::find (ARCH_DEPLETION); |
570 | archetype *at = archetype::find (shstr_depletion); |
570 | |
571 | |
571 | dynbuf_text &buf = msg_dynbuf; buf.clear (); |
572 | dynbuf_text &buf = msg_dynbuf; buf.clear (); |
572 | |
573 | |
573 | if (!op->is_player ()) |
574 | if (!op->is_player ()) |
574 | return 0; |
575 | return 0; |
… | |
… | |
884 | |
885 | |
885 | /* Actually move the player now */ |
886 | /* Actually move the player now */ |
886 | if (!(op = op->map->insert (op, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, op))) |
887 | if (!(op = op->map->insert (op, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, op))) |
887 | return 1; |
888 | return 1; |
888 | |
889 | |
889 | op->speed_left = -FABS (op->speed) * 5; /* Freeze them for a short while */ |
890 | op->speed_left = -5. * op->speed; /* Freeze them for a short while */ |
|
|
891 | |
890 | return 1; |
892 | return 1; |
891 | } |
893 | } |
892 | |
894 | |
893 | /* cast_heal: Heals something. |
895 | /* cast_heal: Heals something. |
894 | * op is the caster. |
896 | * op is the caster. |
… | |
… | |
949 | if (cure_disease (tmp, op, spell)) |
951 | if (cure_disease (tmp, op, spell)) |
950 | success = 1; |
952 | success = 1; |
951 | |
953 | |
952 | if (spell->attacktype & AT_POISON) |
954 | if (spell->attacktype & AT_POISON) |
953 | { |
955 | { |
954 | at = archetype::find ("poisoning"); |
956 | at = archetype::find (shstr_poisoning); |
955 | poison = present_arch_in_ob (at, tmp); |
957 | poison = present_arch_in_ob (at, tmp); |
956 | if (poison) |
958 | if (poison) |
957 | { |
959 | { |
958 | success = 1; |
960 | success = 1; |
959 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your body feels cleansed"); |
961 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your body feels cleansed"); |
… | |
… | |
961 | } |
963 | } |
962 | } |
964 | } |
963 | |
965 | |
964 | if (spell->attacktype & AT_CONFUSION) |
966 | if (spell->attacktype & AT_CONFUSION) |
965 | { |
967 | { |
966 | poison = present_in_ob_by_name (FORCE, "confusion", tmp); |
968 | poison = present_in_ob_by_name (FORCE, shstr_confusion, tmp); |
967 | if (poison) |
969 | if (poison) |
968 | { |
970 | { |
969 | success = 1; |
971 | success = 1; |
970 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
972 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); |
971 | poison->duration = 1; |
973 | poison->duration = 1; |
972 | } |
974 | } |
973 | } |
975 | } |
974 | |
976 | |
975 | if (spell->attacktype & AT_BLIND) |
977 | if (spell->attacktype & AT_BLIND) |
976 | { |
978 | { |
977 | at = archetype::find ("blindness"); |
979 | at = archetype::find (shstr_blindness); |
978 | poison = present_arch_in_ob (at, tmp); |
980 | poison = present_arch_in_ob (at, tmp); |
979 | if (poison) |
981 | if (poison) |
980 | { |
982 | { |
981 | success = 1; |
983 | success = 1; |
982 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your vision begins to return."); |
984 | new_draw_info (NDI_UNIQUE, 0, tmp, "Your vision begins to return."); |
… | |
… | |
1062 | break; |
1064 | break; |
1063 | } |
1065 | } |
1064 | else if (spell_ob->race && spell_ob->race == tmp2->name) |
1066 | else if (spell_ob->race && spell_ob->race == tmp2->name) |
1065 | { |
1067 | { |
1066 | if (!silent) |
1068 | if (!silent) |
1067 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can not cast %s while %s is in effect", &spell_ob->name, &tmp2->name_pl); |
1069 | new_draw_info_format (NDI_UNIQUE, 0, op, |
|
|
1070 | "You can not cast %s while %s is in effect", |
|
|
1071 | &spell_ob->name, &tmp2->name_pl); |
1068 | |
1072 | |
1069 | return 0; |
1073 | return 0; |
1070 | } |
1074 | } |
1071 | } |
1075 | } |
1072 | } |
1076 | } |
1073 | |
1077 | |
1074 | if (!force) |
|
|
1075 | { |
|
|
1076 | force = get_archetype (FORCE_NAME); |
|
|
1077 | force->subtype = FORCE_CHANGE_ABILITY; |
|
|
1078 | |
|
|
1079 | if (spell_ob->race) |
|
|
1080 | force->name = spell_ob->race; |
|
|
1081 | else |
|
|
1082 | force->name = spell_ob->name; |
|
|
1083 | |
|
|
1084 | force->name_pl = spell_ob->name; |
|
|
1085 | new_draw_info (NDI_UNIQUE, 0, op, "You create an aura of magical force."); |
|
|
1086 | |
|
|
1087 | } |
|
|
1088 | else |
|
|
1089 | { |
|
|
1090 | int duration = change_ability_duration (spell_ob, caster); |
1078 | int duration = change_ability_duration (spell_ob, caster); |
1091 | |
1079 | |
|
|
1080 | if (force) |
|
|
1081 | { |
1092 | if (duration > force->duration) |
1082 | if (duration > force->duration) |
1093 | { |
1083 | { |
1094 | force->duration = duration; |
1084 | force->duration = duration; |
1095 | new_draw_info (NDI_UNIQUE, 0, op, "You recast the spell while in effect."); |
1085 | new_draw_info (NDI_UNIQUE, 0, op, "You recast the spell while in effect."); |
1096 | } |
1086 | } |
… | |
… | |
1098 | new_draw_info (NDI_UNIQUE, 0, op, "Recasting the spell had no effect."); |
1088 | new_draw_info (NDI_UNIQUE, 0, op, "Recasting the spell had no effect."); |
1099 | |
1089 | |
1100 | return 1; |
1090 | return 1; |
1101 | } |
1091 | } |
1102 | |
1092 | |
1103 | force->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob) * 50; |
1093 | new_draw_info_format (NDI_UNIQUE, 0, op, |
|
|
1094 | "You create an aura of magical force. H<The effect will last for about %.10g seconds.>", |
|
|
1095 | TICK2TIME (duration)); |
|
|
1096 | |
|
|
1097 | force = get_archetype (FORCE_NAME); |
|
|
1098 | force->subtype = FORCE_CHANGE_ABILITY; |
|
|
1099 | force->duration = duration; |
|
|
1100 | |
|
|
1101 | if (spell_ob->race) |
|
|
1102 | force->name = spell_ob->race; |
|
|
1103 | else |
|
|
1104 | force->name = spell_ob->name; |
|
|
1105 | |
|
|
1106 | force->name_pl = spell_ob->name; |
|
|
1107 | |
1104 | force->speed = 1.0; |
1108 | force->speed = 1.0; |
1105 | force->speed_left = -1.0; |
1109 | force->speed_left = -1.0; |
1106 | SET_FLAG (force, FLAG_APPLIED); |
1110 | SET_FLAG (force, FLAG_APPLIED); |
1107 | |
1111 | |
1108 | /* Now start processing the effects. First, protections */ |
1112 | /* Now start processing the effects. First, protections */ |
… | |
… | |
1246 | } |
1250 | } |
1247 | else |
1251 | else |
1248 | { |
1252 | { |
1249 | /* Only give out good benefits, and put a max on it */ |
1253 | /* Only give out good benefits, and put a max on it */ |
1250 | for (i = 0; i < NROFATTACKS; i++) |
1254 | for (i = 0; i < NROFATTACKS; i++) |
1251 | { |
|
|
1252 | if (god->resist[i] > 0) |
1255 | if (god->resist[i] > 0) |
1253 | { |
|
|
1254 | force->resist[i] = MIN (god->resist[i], spell_ob->resist[ATNR_GODPOWER]); |
1256 | force->resist[i] = min (god->resist[i], spell_ob->resist[ATNR_GODPOWER]); |
1255 | } |
1257 | |
1256 | } |
|
|
1257 | force->path_attuned |= god->path_attuned; |
1258 | force->path_attuned |= god->path_attuned; |
1258 | |
1259 | |
1259 | if (spell_ob->attacktype) |
1260 | if (spell_ob->attacktype) |
1260 | force->slaying = god->slaying; |
1261 | force->slaying = god->slaying; |
1261 | |
1262 | |
… | |
… | |
1326 | if (op->type != PLAYER) |
1327 | if (op->type != PLAYER) |
1327 | return 0; |
1328 | return 0; |
1328 | |
1329 | |
1329 | archetype *nugget[3]; |
1330 | archetype *nugget[3]; |
1330 | |
1331 | |
1331 | nugget[0] = archetype::find ("pyrite3"); |
1332 | nugget[0] = archetype::find (shstr_pyrite3); |
1332 | nugget[1] = archetype::find ("pyrite2"); |
1333 | nugget[1] = archetype::find (shstr_pyrite2); |
1333 | nugget[2] = archetype::find ("pyrite"); |
1334 | nugget[2] = archetype::find (shstr_pyrite); |
1334 | |
1335 | |
1335 | /* Put a maximum weight of items that can be alchemised. Limits the power |
1336 | /* Put a maximum weight of items that can be alchemised. Limits the power |
1336 | * some, and also prevents people from alchemising every table/chair/clock |
1337 | * some, and also prevents people from alchemising every table/chair/clock |
1337 | * in sight |
1338 | * in sight |
1338 | */ |
1339 | */ |
… | |
… | |
1571 | /* show invisible */ |
1572 | /* show invisible */ |
1572 | if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) && |
1573 | if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) && |
1573 | /* Might there be other objects that we can make visible? */ |
1574 | /* Might there be other objects that we can make visible? */ |
1574 | (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) |
1575 | (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) |
1575 | || (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) |
1576 | || (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) |
1576 | || tmp->type == CF_HANDLE |
1577 | || tmp->type == T_HANDLE |
1577 | || tmp->type == TRAPDOOR |
1578 | || tmp->type == TRAPDOOR |
1578 | || tmp->type == EXIT |
1579 | || tmp->type == EXIT |
1579 | || tmp->type == HOLE |
1580 | || tmp->type == HOLE |
1580 | || tmp->type == BUTTON |
1581 | || tmp->type == BUTTON |
1581 | || tmp->type == TELEPORTER |
1582 | || tmp->type == TELEPORTER |
… | |
… | |
2084 | |
2085 | |
2085 | /* attacktype */ |
2086 | /* attacktype */ |
2086 | if (!tmp->attacktype) |
2087 | if (!tmp->attacktype) |
2087 | tmp->attacktype = AT_PHYSICAL; |
2088 | tmp->attacktype = AT_PHYSICAL; |
2088 | |
2089 | |
2089 | if (materialtype_t *mt = name_to_material (op->materialname)) |
|
|
2090 | { |
|
|
2091 | for (i = 0; i < NROFATTACKS; i++) |
2090 | for (i = 0; i < NROFATTACKS; i++) |
2092 | tmp->resist[i] = 50 - (mt->save[i] * 5); |
2091 | tmp->resist[i] = 50 - (op->material->save[i] * 5); |
2093 | a = mt->save[0]; |
2092 | |
2094 | } |
2093 | a = op->material->save[0]; |
2095 | else |
|
|
2096 | { |
|
|
2097 | for (i = 0; i < NROFATTACKS; i++) |
|
|
2098 | tmp->resist[i] = 5; |
|
|
2099 | a = 10; |
|
|
2100 | } |
|
|
2101 | |
2094 | |
2102 | /* Set weapon's immunity */ |
2095 | /* Set weapon's immunity */ |
2103 | tmp->resist[ATNR_CONFUSION] = 100; |
2096 | tmp->resist[ATNR_CONFUSION] = 100; |
2104 | tmp->resist[ATNR_POISON] = 100; |
2097 | tmp->resist[ATNR_POISON] = 100; |
2105 | tmp->resist[ATNR_SLOW] = 100; |
2098 | tmp->resist[ATNR_SLOW] = 100; |
… | |
… | |
2132 | tmp->state = weapon->state; |
2125 | tmp->state = weapon->state; |
2133 | tmp->flag [FLAG_ANIMATE] = weapon->flag [FLAG_ANIMATE]; |
2126 | tmp->flag [FLAG_ANIMATE] = weapon->flag [FLAG_ANIMATE]; |
2134 | } |
2127 | } |
2135 | |
2128 | |
2136 | /* make experience increase in proportion to the strength of the summoned creature. */ |
2129 | /* make experience increase in proportion to the strength of the summoned creature. */ |
2137 | tmp->stats.exp *= 1 + (MAX (spell->stats.maxgrace, spell->stats.sp) / casting_level (caster, spell)); |
2130 | tmp->stats.exp *= 1 + (max (spell->stats.maxgrace, spell->stats.sp) / casting_level (caster, spell)); |
2138 | |
2131 | |
2139 | tmp->speed_left = -1; |
2132 | tmp->speed_left = -1; |
2140 | tmp->direction = dir; |
2133 | tmp->direction = dir; |
2141 | |
2134 | |
2142 | m->insert (tmp, x, y, op); |
2135 | m->insert (tmp, x, y, op); |
… | |
… | |
2285 | continue; |
2278 | continue; |
2286 | |
2279 | |
2287 | if (victim->stats.exp == 0) |
2280 | if (victim->stats.exp == 0) |
2288 | continue; |
2281 | continue; |
2289 | |
2282 | |
2290 | def_lev = MAX (1, victim->level); |
2283 | def_lev = max (1, victim->level); |
2291 | atk_lev = MAX (1, op->level); |
2284 | atk_lev = max (1, op->level); |
2292 | |
2285 | |
2293 | if (rndm (0, atk_lev - 1) > def_lev) |
2286 | if (rndm (0, atk_lev - 1) > def_lev) |
2294 | { |
2287 | { |
2295 | /* make this sucker peaceful. */ |
2288 | /* make this sucker peaceful. */ |
2296 | |
2289 | |
… | |
… | |
2328 | { |
2321 | { |
2329 | new_draw_info (NDI_UNIQUE, 0, op, "Write what?"); |
2322 | new_draw_info (NDI_UNIQUE, 0, op, "Write what?"); |
2330 | return 0; |
2323 | return 0; |
2331 | } |
2324 | } |
2332 | |
2325 | |
2333 | if (strcasestr_local (msg, "endmsg")) |
2326 | if (!msg_is_safe (msg)) |
2334 | { |
2327 | { |
2335 | new_draw_info (NDI_UNIQUE, 0, op, "Trying to cheat are we?"); |
2328 | new_draw_info (NDI_UNIQUE, 0, op, "Trying to cheat are we?"); |
2336 | LOG (llevInfo, "write_rune: player %s tried to write bogus rune %s\n", &op->name, msg); |
2329 | LOG (llevInfo, "write_mark: player %s tried to write bogus rune %s\n", &op->name, msg); |
2337 | return 0; |
2330 | return 0; |
2338 | } |
2331 | } |
2339 | |
2332 | |
2340 | if (!spell->other_arch) |
2333 | if (!spell->other_arch) |
2341 | return 0; |
2334 | return 0; |