ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/spell_effect.C
(Generate patch)

Comparing deliantra/server/server/spell_effect.C (file contents):
Revision 1.69 by root, Thu Aug 23 17:17:41 2007 UTC vs.
Revision 1.75 by root, Sun Oct 21 01:25:02 2007 UTC

125 * create nonnmagic arrows, or even -1, etc... 125 * create nonnmagic arrows, or even -1, etc...
126 */ 126 */
127int 127int
128cast_create_missile (object *op, object *caster, object *spell, int dir, const char *stringarg) 128cast_create_missile (object *op, object *caster, object *spell, int dir, const char *stringarg)
129{ 129{
130 int missile_plus = 0, bonus_plus = 0; 130 int bonus_plus = 0;
131 const char *missile_name; 131 const char *missile_name = "arrow";
132 object *tmp, *missile;
133 132
134 missile_name = "arrow";
135
136 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 133 for (object *tmp = op->inv; tmp; tmp = tmp->below)
137 if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED)) 134 if (tmp->type == BOW && QUERY_FLAG (tmp, FLAG_APPLIED))
138 missile_name = tmp->race; 135 missile_name = tmp->race;
139 136
140 missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell); 137 int missile_plus = spell->stats.dam + SP_level_dam_adjust (caster, spell);
141 138
142 if (archetype::find (missile_name) == NULL) 139 archetype *missile_arch = archetype::find (missile_name);
140
141 if (!missile_arch)
143 { 142 {
144 LOG (llevDebug, "Cast create_missile: could not find archetype %s\n", missile_name); 143 LOG (llevDebug, "Cast create_missile: could not find archetype %s\n", missile_name);
145 return 0; 144 return 0;
146 } 145 }
147 146
148 missile = get_archetype (missile_name); 147 object *missile = missile_arch->instance ();
149 148
150 if (stringarg) 149 if (stringarg)
151 { 150 {
152 /* If it starts with a letter, presume it is a description */ 151 /* If it starts with a letter, presume it is a description */
153 if (isalpha (*stringarg)) 152 if (isalpha (*stringarg))
171 new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg); 170 new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg);
172 return 0; 171 return 0;
173 } 172 }
174 173
175 give_artifact_abilities (missile, al->item); 174 give_artifact_abilities (missile, al->item);
176 /* These special arrows cost something extra. Don't have them also be magical - 175 /* These special arrows cost something extra. Don't have them also be magical -
177 * otherwise, in most cases, not enough will be created. I don't want to get into 176 * otherwise, in most cases, not enough will be created. I don't want to get into
178 * the parsing of having to do both plus and type. 177 * the parsing of having to do both plus and type.
179 */ 178 */
180 bonus_plus = 1 + (al->item->value / 5); 179 bonus_plus = 1 + (al->item->value / 5);
181 missile_plus = 0; 180 missile_plus = 0;
182 } 181 }
183 else if (atoi (stringarg) < missile_plus) 182 else if (atoi (stringarg) < missile_plus)
184 missile_plus = atoi (stringarg); 183 missile_plus = atoi (stringarg);
185 } 184 }
186 185
187 if (missile_plus > 4) 186 missile_plus = clamp (missile_plus, -4, 4);
188 missile_plus = 4;
189 else if (missile_plus < -4)
190 missile_plus = -4;
191 187
192 missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell); 188 missile->nrof = spell->duration + SP_level_duration_adjust (caster, spell);
193 missile->nrof -= 3 * (missile_plus + bonus_plus); 189 missile->nrof -= 3 * (missile_plus + bonus_plus);
194 190
195 if (missile->nrof < 1) 191 if (missile->nrof < 1)
900 896
901 op->speed_left = -FABS (op->speed) * 5; /* Freeze them for a short while */ 897 op->speed_left = -FABS (op->speed) * 5; /* Freeze them for a short while */
902 return 1; 898 return 1;
903} 899}
904 900
905
906/* cast_heal: Heals something. 901/* cast_heal: Heals something.
907 * op is the caster. 902 * op is the caster.
908 * dir is the direction he is casting it in. 903 * dir is the direction he is casting it in.
909 * spell is the spell object. 904 * spell is the spell object.
910 */ 905 */
936 { 931 {
937 /* See how many points we actually heal. Instead of messages 932 /* See how many points we actually heal. Instead of messages
938 * based on type of spell, we instead do messages based 933 * based on type of spell, we instead do messages based
939 * on amount of damage healed. 934 * on amount of damage healed.
940 */ 935 */
941 if (heal > (tmp->stats.maxhp - tmp->stats.hp)) 936 if (heal > tmp->stats.maxhp - tmp->stats.hp)
942 heal = tmp->stats.maxhp - tmp->stats.hp; 937 heal = tmp->stats.maxhp - tmp->stats.hp;
938
943 tmp->stats.hp += heal; 939 tmp->stats.hp += heal;
944 940
945 if (tmp->stats.hp >= tmp->stats.maxhp) 941 if (tmp->stats.hp >= tmp->stats.maxhp)
946 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel just fine!"); 942 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel just fine!");
947 else if (heal > 50) 943 else if (heal > 50)
956 success = 1; 952 success = 1;
957 } 953 }
958 } 954 }
959 955
960 if (spell->attacktype & AT_DISEASE) 956 if (spell->attacktype & AT_DISEASE)
961 if (cure_disease (tmp, op)) 957 if (cure_disease (tmp, op, spell))
962 success = 1; 958 success = 1;
963 959
964 if (spell->attacktype & AT_POISON) 960 if (spell->attacktype & AT_POISON)
965 { 961 {
966 at = archetype::find ("poisoning"); 962 at = archetype::find ("poisoning");
1015 } 1011 }
1016 1012
1017 if (spell->stats.food && tmp->stats.food < 999) 1013 if (spell->stats.food && tmp->stats.food < 999)
1018 { 1014 {
1019 tmp->stats.food += spell->stats.food; 1015 tmp->stats.food += spell->stats.food;
1016
1020 if (tmp->stats.food > 999) 1017 if (tmp->stats.food > 999)
1021 tmp->stats.food = 999; 1018 tmp->stats.food = 999;
1019
1022 success = 1; 1020 success = 1;
1023 /* We could do something a bit better like the messages for healing above */ 1021 /* We could do something a bit better like the messages for healing above */
1024 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel your belly fill with food"); 1022 new_draw_info (NDI_UNIQUE, 0, tmp, "You feel your belly fill with food");
1025 } 1023 }
1026 1024
1297static void 1295static void
1298alchemy_object (object *obj, uint64 &total_value, int &total_weight) 1296alchemy_object (object *obj, uint64 &total_value, int &total_weight)
1299{ 1297{
1300 uint64 value = query_cost (obj, NULL, F_TRUE); 1298 uint64 value = query_cost (obj, NULL, F_TRUE);
1301 1299
1302 /* Give third price when we alchemy money (This should hopefully 1300 /* Give third price when we alchemy money (this should hopefully
1303 * make it so that it isn't worth it to alchemy money, sell 1301 * make it so that it isn't worth it to alchemy money, sell
1304 * the nuggets, alchemy the gold from that, etc. 1302 * the nuggets, alchemy the gold from that, etc.
1305 * Otherwise, give 9 silver on the gold for other objects, 1303 * Otherwise, give 9 silver on the gold for other objects,
1306 * so that it would still be more affordable to haul 1304 * so that it would still be more affordable to haul
1307 * the stuff back to town. 1305 * the stuff back to town.
1461 1459
1462 return success; 1460 return success;
1463} 1461}
1464 1462
1465/* Identifies objects in the players inventory/on the ground */ 1463/* Identifies objects in the players inventory/on the ground */
1466
1467int 1464int
1468cast_identify (object *op, object *caster, object *spell) 1465cast_identify (object *op, object *caster, object *spell)
1469{ 1466{
1467 dynbuf_text buf;
1470 object *tmp; 1468 object *tmp;
1471 int success = 0, num_ident;
1472 1469
1473 num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1470 int num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell);
1474 1471
1475 if (num_ident < 1) 1472 if (num_ident < 1)
1476 num_ident = 1; 1473 num_ident = 1;
1477 1474
1478 for (tmp = op->inv; tmp; tmp = tmp->below) 1475 for (tmp = op->inv; tmp; tmp = tmp->below)
1481 { 1478 {
1482 identify (tmp); 1479 identify (tmp);
1483 1480
1484 if (op->type == PLAYER) 1481 if (op->type == PLAYER)
1485 { 1482 {
1486 new_draw_info_format (NDI_UNIQUE, 0, op, "You identified: %s.", long_desc (tmp, op)); 1483 buf.printf ("You identified: %s.\n\n", long_desc (tmp, op));
1487 1484
1488 if (tmp->msg) 1485 if (tmp->msg)
1489 { 1486 buf << "The item has a story:\n\n" << tmp->msg << "\n\n";
1490 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:");
1491 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg);
1492 }
1493 } 1487 }
1494 1488
1495 num_ident--; 1489 num_ident--;
1496 success = 1;
1497 if (!num_ident) 1490 if (!num_ident)
1498 break; 1491 break;
1499 } 1492 }
1500 } 1493 }
1501 1494
1510 { 1503 {
1511 identify (tmp); 1504 identify (tmp);
1512 1505
1513 if (op->type == PLAYER) 1506 if (op->type == PLAYER)
1514 { 1507 {
1515 new_draw_info_format (NDI_UNIQUE, 0, op, "On the ground you identified: %s.", long_desc (tmp, op)); 1508 buf.printf ("On the ground you identified: %s.\n\n", long_desc (tmp, op));
1516 1509
1517 if (tmp->msg) 1510 if (tmp->msg)
1518 { 1511 buf << "The item has a story:\n\n" << tmp->msg << "\n\n";
1519 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:");
1520 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg);
1521 }
1522 1512
1523 esrv_send_item (op, tmp); 1513 esrv_send_item (op, tmp);
1524 } 1514 }
1525 1515
1526 num_ident--; 1516 num_ident--;
1527 success = 1;
1528 if (!num_ident) 1517 if (!num_ident)
1529 break; 1518 break;
1530 } 1519 }
1531 } 1520 }
1532 1521
1533 if (!success) 1522 if (buf.empty ())
1534 new_draw_info (NDI_UNIQUE, 0, op, "You can't reach anything unidentified."); 1523 {
1524 op->failmsg ("You can't reach anything unidentified.");
1525 return 0;
1526 }
1535 else 1527 else
1528 {
1529 if (op->contr)
1530 op->contr->infobox (MSG_CHANNEL ("identify"), buf);
1531
1536 spell_effect (spell, op->x, op->y, op->map, op); 1532 spell_effect (spell, op->x, op->y, op->map, op);
1537 1533 return 1;
1538 return success; 1534 }
1539} 1535}
1540 1536
1541int 1537int
1542cast_detection (object *op, object *caster, object *spell, object *skill) 1538cast_detection (object *op, object *caster, object *spell, object *skill)
1543{ 1539{
2172 new_draw_info (NDI_UNIQUE, 0, op, "It can be no darker here."); 2168 new_draw_info (NDI_UNIQUE, 0, op, "It can be no darker here.");
2173 } 2169 }
2174 return success; 2170 return success;
2175} 2171}
2176 2172
2177
2178
2179
2180
2181/* create an aura spell object and put it in the player's inventory. 2173/* create an aura spell object and put it in the player's inventory.
2182 * as usual, op is player, caster is the object casting the spell, 2174 * as usual, op is player, caster is the object casting the spell,
2183 * spell is the spell object itself. 2175 * spell is the spell object itself.
2184 */ 2176 */
2185int 2177int
2196 2188
2197 new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell); 2189 new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell);
2198 2190
2199 new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 2191 new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
2200 2192
2201 new_aura->set_owner (op);
2202 set_spell_skill (op, caster, spell, new_aura); 2193 set_spell_skill (op, caster, spell, new_aura);
2203 new_aura->attacktype = spell->attacktype; 2194 new_aura->attacktype = spell->attacktype;
2204 2195
2205 new_aura->level = caster_level (caster, spell); 2196 new_aura->level = caster_level (caster, spell);
2197
2206 if (refresh) 2198 if (refresh)
2207 new_draw_info (NDI_UNIQUE, 0, op, "You recast the spell while in effect."); 2199 new_draw_info (NDI_UNIQUE, 0, op, "You recast the spell while in effect.");
2208 else 2200 else
2209 new_draw_info (NDI_UNIQUE, 0, op, "You create an aura of magical force."); 2201 new_draw_info (NDI_UNIQUE, 0, op, "You create an aura of magical force.");
2202
2210 insert_ob_in_ob (new_aura, op); 2203 insert_ob_in_ob (new_aura, op);
2204 new_aura->set_owner (op);
2205
2211 return 1; 2206 return 1;
2212} 2207}
2213
2214 2208
2215/* move aura function. An aura is a part of someone's inventory, 2209/* move aura function. An aura is a part of someone's inventory,
2216 * which he carries with him, but which acts on the map immediately 2210 * which he carries with him, but which acts on the map immediately
2217 * around him. 2211 * around him.
2218 * Aura parameters: 2212 * Aura parameters:
2219 * duration: duration counter. 2213 * duration: duration counter.
2220 * attacktype: aura's attacktype 2214 * attacktype: aura's attacktype
2221 * other_arch: archetype to drop where we attack 2215 * other_arch: archetype to drop where we attack
2222 */ 2216 */
2223
2224void 2217void
2225move_aura (object *aura) 2218move_aura (object *aura)
2226{ 2219{
2227 int i, mflags;
2228 object *env;
2229 maptile *m;
2230
2231 /* auras belong in inventories */ 2220 /* auras belong in inventories */
2232 env = aura->env; 2221 object *env = aura->env;
2222 object *owner = aura->owner;
2233 2223
2234 /* no matter what we've gotta remove the aura... 2224 /* no matter what we've gotta remove the aura...
2235 * we'll put it back if its time isn't up. 2225 * we'll put it back if its time isn't up.
2236 */ 2226 */
2237 aura->remove (); 2227 aura->remove ();
2242 aura->destroy (); 2232 aura->destroy ();
2243 return; 2233 return;
2244 } 2234 }
2245 2235
2246 /* auras only exist in inventories */ 2236 /* auras only exist in inventories */
2247 if (env == NULL || env->map == NULL) 2237 if (!env || !env->map)
2248 { 2238 {
2249 aura->destroy (); 2239 aura->destroy ();
2250 return; 2240 return;
2251 } 2241 }
2252 2242
2253 /* we need to jump out of the inventory for a bit 2243 /* we need to jump out of the inventory for a bit
2254 * in order to hit the map conveniently. 2244 * in order to hit the map conveniently.
2255 */ 2245 */
2256 aura->insert_at (env, aura); 2246 aura->insert_at (env, aura);
2257 2247
2258 for (i = 1; i < 9; i++) 2248 for (int i = 1; i < 9; i++)
2259 { 2249 {
2260 sint16 nx, ny; 2250 mapxy pos (env);
2251 pos.move (i);
2261 2252
2262 nx = aura->x + freearr_x[i];
2263 ny = aura->y + freearr_y[i];
2264 mflags = get_map_flags (env->map, &m, nx, ny, &nx, &ny);
2265
2266 /* Consider the movement tyep of the person with the aura as 2253 /* Consider the movement type of the person with the aura as
2267 * movement type of the aura. Eg, if the player is flying, the aura 2254 * movement type of the aura. Eg, if the player is flying, the aura
2268 * is flying also, if player is walking, it is on the ground, etc. 2255 * is flying also, if player is walking, it is on the ground, etc.
2269 */ 2256 */
2270 if (!(mflags & P_OUT_OF_MAP) && !(OB_TYPE_MOVE_BLOCK (env, GET_MAP_MOVE_BLOCK (m, nx, ny)))) 2257 if (pos.normalise () && !(OB_TYPE_MOVE_BLOCK (env, pos->move_block)))
2271 { 2258 {
2272 hit_map (aura, i, aura->attacktype, 0); 2259 hit_map (aura, i, aura->attacktype, 0);
2273 2260
2274 if (aura->other_arch) 2261 if (aura->other_arch)
2275 m->insert (arch_to_object (aura->other_arch), nx, ny, aura); 2262 pos.insert (arch_to_object (aura->other_arch), aura);
2276 } 2263 }
2277 } 2264 }
2278 2265
2279 /* put the aura back in the player's inventory */ 2266 /* put the aura back in the player's inventory */
2280 aura->remove (); 2267 env->insert (aura);
2281 insert_ob_in_ob (aura, env); 2268 aura->set_owner (owner);
2282} 2269}
2283 2270
2284/* moves the peacemaker spell. 2271/* moves the peacemaker spell.
2285 * op is the piece object. 2272 * op is the piece object.
2286 */ 2273 */
2287
2288void 2274void
2289move_peacemaker (object *op) 2275move_peacemaker (object *op)
2290{ 2276{
2291 object *tmp; 2277 object *tmp;
2292 2278

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines