--- deliantra/server/server/spell_effect.C 2007/06/02 03:34:48 1.55
+++ deliantra/server/server/spell_effect.C 2007/08/01 00:26:04 1.65
@@ -5,19 +5,18 @@
* Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
* Copyright (©) 1992,2007 Frank Tore Johansen
*
- * Crossfire TRT is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
+ * Crossfire TRT is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along
- * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*
* The authors can be reached via e-mail to
*/
@@ -72,7 +71,7 @@
if (!(random_roll (0, 3, op, PREFER_HIGH)))
{
new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand));
- play_sound_map (op->map, op->x, op->y, SOUND_OB_EXPLODE);
+ op->play_sound (sound_find ("ob_explode"));
esrv_del_item (op->contr, wand->count);
wand->destroy ();
tmp = get_archetype ("fireball");
@@ -106,10 +105,10 @@
wand->stats.food += ncharges;
new_draw_info_format (NDI_UNIQUE, 0, op, "The %s glows with power.", query_name (wand));
- if (wand->arch && QUERY_FLAG (&wand->arch->clone, FLAG_ANIMATE))
+ if (wand->arch && QUERY_FLAG (wand->arch, FLAG_ANIMATE))
{
SET_FLAG (wand, FLAG_ANIMATE);
- wand->set_speed (wand->arch->clone.speed);
+ wand->set_speed (wand->arch->speed);
}
return 1;
@@ -125,7 +124,6 @@
* wants LOTS of arrows, and doesn't care what the plus is he could
* create nonnmagic arrows, or even -1, etc...
*/
-
int
cast_create_missile (object *op, object *caster, object *spell, int dir, const char *stringarg)
{
@@ -226,7 +224,7 @@
at = find_archetype_by_object_type_name (FOOD, stringarg);
if (at == NULL)
at = find_archetype_by_object_type_name (DRINK, stringarg);
- if (at == NULL || at->clone.stats.food > food_value)
+ if (at == NULL || at->stats.food > food_value)
stringarg = NULL;
}
@@ -242,19 +240,24 @@
*/
/* We assume the food items don't have multiple parts */
- for (at_tmp = first_archetype; at_tmp != NULL; at_tmp = at_tmp->next)
+ for_all_archetypes (at_tmp)
{
- if (at_tmp->clone.type == FOOD || at_tmp->clone.type == DRINK)
+ if (at_tmp->type == FOOD || at_tmp->type == DRINK)
{
/* Basically, if the food value is something that is creatable
* under the limits of the spell and it is higher than
* the item we have now, take it instead.
*/
- if (at_tmp->clone.stats.food <= food_value && (!at || at_tmp->clone.stats.food > at->clone.stats.food))
+ if (at_tmp->stats.food <= food_value
+ && (!at
+ || at_tmp->stats.food > at->stats.food
+ || (at_tmp->stats.food == at->stats.food
+ && at_tmp->weight < at->weight)))
at = at_tmp;
}
}
}
+
/* Pretty unlikely (there are some very low food items), but you never
* know
*/
@@ -264,7 +267,7 @@
return 0;
}
- food_value /= at->clone.stats.food;
+ food_value /= at->stats.food;
new_op = arch_to_object (at);
new_op->nrof = food_value;
@@ -289,6 +292,7 @@
examine_monster (op, op);
return 1;
}
+
maxrange = spell_ob->range + SP_level_range_adjust (caster, spell_ob);
for (r = 1; r < maxrange; r++)
{
@@ -318,11 +322,11 @@
}
}
}
+
new_draw_info (NDI_UNIQUE, 0, op, "You detect nothing.");
return 1;
}
-
/* This checks to see if 'pl' is invisible to 'mon'.
* does race check, undead check, etc
* Returns TRUE if mon can't see pl, false
@@ -567,50 +571,52 @@
int
perceive_self (object *op)
{
- char buf[MAX_BUF];
const char *cp = describe_item (op, op);
archetype *at = archetype::find (ARCH_DEPLETION);
- object *tmp;
- int i;
- tmp = find_god (determine_god (op));
- if (tmp)
- new_draw_info_format (NDI_UNIQUE, 0, op, "You worship %s", &tmp->name);
+ dynbuf_text buf;
+
+ if (player *pl = op->contr)
+ if (object *race = archetype::find (op->race))
+ buf << "You are a " << (pl->gender ? "female" : "male") << " " << &race->name << ".\n";
+
+ if (object *god = find_god (determine_god (op)))
+ buf << "You worship " << &god->name << ".\n";
else
- new_draw_info (NDI_UNIQUE, 0, op, "You worship no god");
+ buf << "You worship no god.\n";
- tmp = present_arch_in_ob (at, op);
+ object *tmp = present_arch_in_ob (at, op);
if (*cp == '\0' && tmp == NULL)
- new_draw_info (NDI_UNIQUE, 0, op, "You feel very mundane");
+ buf << "You feel very mundane. ";
else
{
- new_draw_info (NDI_UNIQUE, 0, op, "You have:");
- new_draw_info (NDI_UNIQUE, 0, op, cp);
+ buf << "You have: " << cp << ".\n";
if (tmp)
- for (i = 0; i < NUM_STATS; i++)
+ for (int i = 0; i < NUM_STATS; i++)
if (tmp->stats.stat (i) < 0)
- new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is depleted by %d", statname[i], -tmp->stats.stat (i));
+ buf.printf ("Your %s is depleted by %d.\n", statname[i], -tmp->stats.stat (i));
}
if (is_dragon_pl (op))
- {
- /* now grab the 'dragon_ability'-force from the player's inventory */
- for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
- {
- if (tmp->type == FORCE && !strcmp (tmp->arch->name, "dragon_ability_force"))
- {
- if (tmp->stats.exp == 0)
- sprintf (buf, "Your metabolism isn't focused on anything.");
- else
- sprintf (buf, "Your metabolism is focused on %s.", change_resist_msg[tmp->stats.exp]);
+ /* now grab the 'dragon_ability'-force from the player's inventory */
+ for (tmp = op->inv; tmp; tmp = tmp->below)
+ {
+ if (tmp->type == FORCE && !strcmp (tmp->arch->archname, "dragon_ability_force"))
+ {
+ if (tmp->stats.exp == 0)
+ buf << "Your metabolism isn't focused on anything.\n";
+ else
+ buf << "Your metabolism is focused on " << change_resist_msg[tmp->stats.exp] << ".\n";
- new_draw_info (NDI_UNIQUE, 0, op, buf);
- break;
- }
- }
- }
+ break;
+ }
+ }
+
+ buf << '\0'; // zero-terminate
+
+ new_draw_info (NDI_UNIQUE, 0, op, buf.linearise ());
return 1;
}
@@ -718,7 +724,7 @@
}
/* If this is a spellcasting wall, need to insert the spell object */
- if (tmp->other_arch && tmp->other_arch->clone.type == SPELL)
+ if (tmp->other_arch && tmp->other_arch->type == SPELL)
insert_ob_in_ob (arch_to_object (tmp->other_arch), tmp);
/* This code causes the wall to extend some distance in
@@ -748,7 +754,7 @@
m->insert (tmp2, x, y, op);
/* If this is a spellcasting wall, need to insert the spell object */
- if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL)
+ if (tmp2->other_arch && tmp2->other_arch->type == SPELL)
tmp2->insert (arch_to_object (tmp2->other_arch));
}
@@ -765,7 +771,7 @@
object *tmp2 = tmp->clone ();
m->insert (tmp2, x, y, op);
- if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL)
+ if (tmp2->other_arch && tmp2->other_arch->type == SPELL)
tmp2->insert (arch_to_object (tmp2->other_arch));
}
else
@@ -1995,7 +2001,6 @@
int a, i;
sint16 x, y;
maptile *m;
- materialtype_t *mt;
if (!spell->other_arch)
{
@@ -2024,7 +2029,7 @@
/* if there's no place to put the golem, abort */
if ((dir == -1) || (get_map_flags (m, &m, x, y, &x, &y) & P_OUT_OF_MAP) ||
- ((spell->other_arch->clone.move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->clone.move_type))
+ ((spell->other_arch->move_type & GET_MAP_MOVE_BLOCK (m, x, y)) == spell->other_arch->move_type))
{
new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way.");
return 0;
@@ -2038,7 +2043,7 @@
new_draw_info (NDI_BLACK, 0, op, "You must mark a weapon to use with this spell!");
return 0;
}
- if (spell->race && strcmp (weapon->arch->name, spell->race))
+ if (spell->race && strcmp (weapon->arch->archname, spell->race))
{
new_draw_info (NDI_UNIQUE, 0, op, "The spell fails to transform your weapon.");
return 0;
@@ -2117,10 +2122,7 @@
if (!tmp->attacktype)
tmp->attacktype = AT_PHYSICAL;
- mt = NULL;
- if (op->materialname != NULL)
- mt = name_to_material (op->materialname);
- if (mt != NULL)
+ if (materialtype_t *mt = name_to_material (op->materialname))
{
for (i = 0; i < NROFATTACKS; i++)
tmp->resist[i] = 50 - (mt->save[i] * 5);
@@ -2132,6 +2134,7 @@
tmp->resist[i] = 5;
a = 10;
}
+
/* Set weapon's immunity */
tmp->resist[ATNR_CONFUSION] = 100;
tmp->resist[ATNR_POISON] = 100;
@@ -2147,6 +2150,7 @@
if (a > 14)
a = 14;
+
tmp->resist[ATNR_PHYSICAL] = 100 - (int) ((100.0 - (float) tmp->resist[ATNR_PHYSICAL]) / (30.0 - 2.0 * a));
/* Determine golem's speed */