--- deliantra/server/server/spell_attack.C 2006/12/26 20:04:09 1.25 +++ deliantra/server/server/spell_attack.C 2007/08/01 00:26:03 1.45 @@ -1,25 +1,25 @@ /* - CrossFire, A Multiplayer game for X-windows - - Copyright (C) 2002-2003 Mark Wedel & Crossfire Development Team - Copyright (C) 1992 Frank Tore Johansen - - This program 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. - - 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - The authors can be reached via e-mail at -*/ + * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. + * + * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team + * Copyright (©) 2002-2003,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 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. + * + * 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 + */ /* This file contains all the spell attack code. Grouping this code * together should hopefully make it easier to find the relevent bits @@ -146,7 +146,7 @@ new_bolt->stats.Dex -= 10; tmp->stats.Dex -= 10; /* less forks from main bolt too */ new_bolt->stats.Con += 25 * new_dir; /* adjust the left bias */ - new_bolt->speed_left = -0.1; + new_bolt->speed_left = -0.1f; new_bolt->direction = t_dir; new_bolt->duration++; new_bolt->stats.dam /= 2; /* reduce daughter bolt damage */ @@ -164,7 +164,6 @@ void move_bolt (object *op) { - object *tmp; int mflags; sint16 x, y; maptile *m; @@ -247,7 +246,7 @@ object *tmp = op->clone (); m->insert (tmp, x, y, op); - tmp->speed_left = -0.1; + tmp->speed_left = -0.1f; /* To make up for the decrease at the top of the function */ tmp->duration++; @@ -339,8 +338,6 @@ return 1; } - - /*************************************************************************** * * BULLET/BALL CODE @@ -382,7 +379,7 @@ object *tmp = op->clone (); tmp->state = 0; - tmp->speed_left = -0.21; + tmp->speed_left = -0.21f; tmp->range--; tmp->value = 0; @@ -392,7 +389,6 @@ } } - /* Causes an object to explode, eg, a firebullet, * poison cloud ball, etc. op is the object to * explode. @@ -489,6 +485,8 @@ op->move_on = 0; tmp->insert_at (op, op); + tmp->play_sound (tmp->sound); + /* remove the firebullet */ op->destroy (); } @@ -520,7 +518,7 @@ if (!(mflags & P_IS_ALIVE)) return; - for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) + for (tmp = op->ms ().bot; tmp; tmp = tmp->above) { if (QUERY_FLAG (tmp, FLAG_ALIVE)) { @@ -606,9 +604,6 @@ check_bullet (op); } - - - /* fire_bullet * object op (cast from caster) files a bolt in dir. * spob is the spell object for the bolt. @@ -617,7 +612,6 @@ * This function sets up the appropriate owner and skill * pointers. */ - int fire_bullet (object *op, object *caster, int dir, object *spob) { @@ -685,16 +679,12 @@ return 1; } - - - /***************************************************************************** * * CONE RELATED FUNCTIONS * *****************************************************************************/ - /* drops an object based on what is in the cone's "other_arch" */ void cone_drop (object *op) @@ -829,7 +819,7 @@ * to create is, so we can know if the space we are about to * insert it into is blocked. */ - movetype = spell->other_arch->clone.move_type; + movetype = spell->other_arch->move_type; for (i = range_min; i <= range_max; i++) { @@ -918,10 +908,10 @@ } if (!(tmp->move_type & MOVE_FLY_LOW)) - LOG (llevDebug, "cast_cone(): arch %s doesn't have flying 1\n", &spell->other_arch->name); + LOG (llevDebug, "cast_cone(): arch %s doesn't have flying 1\n", &spell->other_arch->archname); if (!tmp->move_on && tmp->stats.dam) - LOG (llevDebug, "cast_cone(): arch %s doesn't have move_on set\n", &spell->other_arch->name); + LOG (llevDebug, "cast_cone(): arch %s doesn't have move_on set\n", &spell->other_arch->archname); m->insert (tmp, sx, sy, op); @@ -943,7 +933,6 @@ * ****************************************************************************/ - /* This handles an exploding bomb. * op is the original bomb object. */ @@ -1056,7 +1045,6 @@ * type is the type of spell - either SPELL_MANA or SPELL_GRACE. * this info is used for blocked magic/unholy spaces. */ - object * get_pointed_target (object *op, int dir, int range, int type) { @@ -1085,20 +1073,14 @@ return NULL; if (mflags & P_IS_ALIVE) - { - for (target = GET_MAP_OB (mp, x, y); target; target = target->above) - { - if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER)) - { - return target; - } - } - } + for (target = GET_MAP_OB (mp, x, y); target; target = target->above) + if (QUERY_FLAG (target, FLAG_MONSTER)) + return target; } + return NULL; } - /* cast_smite_arch() - the priest points to a creature and causes * a 'godly curse' to decend. * usual params - @@ -1107,7 +1089,6 @@ * dir = direction being cast * spell = spell object */ - int cast_smite_spell (object *op, object *caster, int dir, object *spell) { @@ -1275,17 +1256,14 @@ * make this work for non-living objects, we would have to * give them the capability to have an inventory. b.t. */ - int make_object_glow (object *op, int radius, int time) { - object *tmp; - /* some things are unaffected... */ if (op->path_denied & PATH_LIGHT) return 0; - tmp = get_archetype (FORCE_NAME); + object *tmp = get_archetype (FORCE_NAME); tmp->speed = 0.01; tmp->stats.food = time; SET_FLAG (tmp, FLAG_IS_USED_UP); @@ -1293,25 +1271,14 @@ if (tmp->glow_radius > MAX_LIGHT_RADII) tmp->glow_radius = MAX_LIGHT_RADII; - tmp->x = op->x; - tmp->y = op->y; - if (tmp->speed < MIN_ACTIVE_SPEED) - tmp->speed = MIN_ACTIVE_SPEED; /* safety */ tmp = insert_ob_in_ob (tmp, op); + if (tmp->glow_radius > op->glow_radius) op->glow_radius = tmp->glow_radius; - if (!tmp->env || op != tmp->env) - { - LOG (llevError, "make_object_glow() failed to insert glowing force in %s\n", &op->name); - return 0; - } return 1; } - - - int cast_destruction (object *op, object *caster, object *spell_ob) { @@ -1341,7 +1308,7 @@ else op->skill = NULL; - change_skill (op, find_skill_by_name (op, op->skill), 1); + op->change_skill (find_skill_by_name (op, op->skill)); for (i = -range; i < range; i++) { @@ -1455,8 +1422,8 @@ return 1; } force->duration = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob) * 50; - force->speed = 1.0; - force->speed_left = -1.0; + force->speed = 1.f; + force->speed_left = -1.f; SET_FLAG (force, FLAG_APPLIED); if (god) @@ -1484,7 +1451,6 @@ } - /********************************************************************** * mood change * Arguably, this may or may not be an attack spell. But since it @@ -1523,11 +1489,9 @@ else race = spell->race; - for (x = op->x - range; x <= op->x + range; x++) for (y = op->y - range; y <= op->y + range; y++) { - done_one = 0; m = op->map; nx = x; @@ -1540,7 +1504,12 @@ if (!(mflags & P_IS_ALIVE)) continue; - for (tmp = GET_MAP_OB (m, nx, ny); tmp; tmp = tmp->above) + // players can only affect spaces that they can actually see + if (caster && caster->contr + && caster->contr->visibility_at (m, nx, ny) < 70) + continue; + + for (tmp = GET_MAP_TOP (m, nx, ny); tmp; tmp = tmp->below) if (QUERY_FLAG (tmp, FLAG_MONSTER)) break; @@ -1557,6 +1526,7 @@ /* Make sure the race is OK. Likewise, only effect undead if spell specifically allows it */ if (race && head->race && !strstr (race, head->race)) continue; + if (QUERY_FLAG (head, FLAG_UNDEAD) && !QUERY_FLAG (spell, FLAG_UNDEAD)) continue; @@ -1583,35 +1553,34 @@ continue; } else /* spell->attacktype */ - /* - Spell has no attacktype (charm & such), so we'll have a specific saving: - * if spell level < monster level, no go - * else, chance of effect = 20 + min( 50, 2 * ( spell level - monster level ) ) + { + /* + Spell has no attacktype (charm & such), so we'll have a specific saving: + * if spell level < monster level, no go + * else, chance of effect = 20 + min( 50, 2 * ( spell level - monster level ) ) - The chance will then be in the range [20-70] percent, not too bad. + The chance will then be in the range [20-70] percent, not too bad. - This is required to fix the 'charm monster' abuse, where a player level 1 can - charm a level 125 monster... + This is required to fix the 'charm monster' abuse, where a player level 1 can + charm a level 125 monster... - Ryo, august 14th - */ - { + Ryo, august 14th + */ if (head->level > level) continue; + if (random_roll (0, 100, caster, PREFER_LOW) >= (20 + MIN (50, 2 * (level - head->level)))) /* Failed, no effect */ continue; } - /* Done with saving throw. Now start effecting the monster */ + /* Done with saving throw. Now start affecting the monster */ /* aggravation */ if (QUERY_FLAG (spell, FLAG_MONSTER)) { CLEAR_FLAG (head, FLAG_SLEEP); - if (QUERY_FLAG (head, FLAG_FRIENDLY)) - remove_friendly_object (head); - + remove_friendly_object (head); done_one = 1; head->enemy = op; } @@ -1630,10 +1599,10 @@ SET_FLAG (head, FLAG_BERSERK); done_one = 1; } + /* charm */ if (QUERY_FLAG (spell, FLAG_NO_ATTACK) && !QUERY_FLAG (head, FLAG_FRIENDLY)) { - SET_FLAG (head, FLAG_FRIENDLY); /* Prevent uncontolled outbreaks of self replicating monsters. Typical use case is charm, go somwhere, use aggravation to make hostile. This could lead to fun stuff like mice outbreak in bigworld and server crawl. */ @@ -1721,8 +1690,6 @@ */ for (j = 0; j < 9; j++) { - object *new_ob; - hx = nx + freearr_x[j]; hy = ny + freearr_y[j]; @@ -1808,7 +1775,7 @@ // (a wall 2 cells away will block the effect...) and // doesn't work for SP_BULLET anyhow, so again tests the wrong // space. - // should be fixed later, but correctness before featurs... + // should be fixed later, but correctness before features... // (schmorp) /* new offset calculation to make swarm element distribution @@ -2108,12 +2075,10 @@ if (infect_object (walk, disease, 1)) { - object *flash; /* visual effect for inflicting disease */ - new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); disease->destroy (); /* don't need this one anymore */ - walk->map->insert (get_archetype (ARCH_DETECT_MAGIC), x, y, op); + walk->map->insert (get_archetype ("detect_magic"), x, y, op); return 1; }