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

Comparing deliantra/server/server/apply.C (file contents):
Revision 1.209 by root, Fri Nov 6 12:49:19 2009 UTC vs.
Revision 1.213 by elmex, Mon Nov 9 13:38:36 2009 UTC

204 op->update_stats (); 204 op->update_stats ();
205 tmp->decrease (); 205 tmp->decrease ();
206 return 1; 206 return 1;
207 } 207 }
208 208
209 if (!(at = archetype::find (ARCH_DEPLETION))) 209 if (!(at = archetype::find (shstr_depletion)))
210 { 210 {
211 LOG (llevError, "Could not find archetype depletion\n"); 211 LOG (llevError, "Could not find archetype depletion\n");
212 return 0; 212 return 0;
213 } 213 }
214 214
231 } 231 }
232 232
233 /* improvement potion - only for players */ 233 /* improvement potion - only for players */
234 if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER)) 234 if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER))
235 { 235 {
236 for (i = 1; i < MIN (11, op->level); i++) 236 for (i = 1; i < min (11, op->level); i++)
237 { 237 {
238 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 238 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
239 { 239 {
240 if (op->contr->levhp[i] != 1) 240 if (op->contr->levhp[i] != 1)
241 { 241 {
276 } 276 }
277 } 277 }
278 } 278 }
279 279
280 /* Just makes checking easier */ 280 /* Just makes checking easier */
281 if (i < MIN (11, op->level)) 281 if (i < min (11, op->level))
282 got_one = 1; 282 got_one = 1;
283 283
284 if (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED)) 284 if (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED))
285 { 285 {
286 if (got_one) 286 if (got_one)
531 531
532/** 532/**
533 * This does the prepare weapon scroll. 533 * This does the prepare weapon scroll.
534 * Checks for sacrifice, and so on. 534 * Checks for sacrifice, and so on.
535 */ 535 */
536int 536static int
537prepare_weapon (object *op, object *improver, object *weapon) 537prepare_weapon (object *op, object *improver, object *weapon)
538{ 538{
539 int sacrifice_count, i; 539 int sacrifice_count, i;
540 char buf[MAX_BUF]; 540 char buf[MAX_BUF];
541 541
594 * 594 *
595 * We are hiding extra information about the weapon in the level and 595 * We are hiding extra information about the weapon in the level and
596 * last_eat numbers for an object. Hopefully this won't break anything ?? 596 * last_eat numbers for an object. Hopefully this won't break anything ??
597 * level == max improve last_eat == current improve 597 * level == max improve last_eat == current improve
598 */ 598 */
599int 599static int
600improve_weapon (object *op, object *improver, object *weapon) 600improve_weapon (object *op, object *improver, object *weapon)
601{ 601{
602 int sacrifice_count, sacrifice_needed = 0; 602 int sacrifice_count, sacrifice_needed = 0;
603 603
604 if (improver->stats.sp == IMPROVE_PREPARE) 604 if (improver->stats.sp == IMPROVE_PREPARE)
763 * the armour value of the piece of equipment exceed either 763 * the armour value of the piece of equipment exceed either
764 * the users level or 90) 764 * the users level or 90)
765 * Modified by MSW for partial resistance. Only support 765 * Modified by MSW for partial resistance. Only support
766 * changing of physical area right now. 766 * changing of physical area right now.
767 */ 767 */
768int 768static int
769improve_armour (object *op, object *improver, object *armour) 769improve_armour (object *op, object *improver, object *armour)
770{ 770{
771 object *tmp; 771 object *tmp;
772 772
773 if (armour->magic >= settings.armor_max_enchant) 773 if (armour->magic >= settings.armor_max_enchant)
860 * what the converter wants, this will not do anything. 860 * what the converter wants, this will not do anything.
861 */ 861 */
862int 862int
863convert_item (object *item, object *converter) 863convert_item (object *item, object *converter)
864{ 864{
865 sint64 nr, price_in; 865 sint64 nr = 0, price_in;
866 866
867 if (item->flag [FLAG_UNPAID]) 867 if (item->flag [FLAG_UNPAID])
868 return 0; 868 return 0;
869 869
870 shstr conv_from = converter->slaying; 870 shstr conv_from = converter->slaying;
871 archetype *conv_to = converter->other_arch; 871 archetype *conv_to = converter->other_arch;
872 sint64 need = converter->stats.food; 872 sint64 need = converter->stats.food;
873 sint64 give = converter->stats.sp; 873 sint64 give = converter->stats.sp;
874 874
1353 trap->stats.maxsp = 2; 1353 trap->stats.maxsp = 2;
1354 1354
1355 /* Is this correct? From the docs, it doesn't look like it 1355 /* Is this correct? From the docs, it doesn't look like it
1356 * should be divided by trap->speed 1356 * should be divided by trap->speed
1357 */ 1357 */
1358 victim->speed_left = -FABS (trap->stats.maxsp * victim->speed / trap->speed); 1358 victim->speed_left = -fabs (trap->stats.maxsp * victim->speed / trap->speed);
1359 1359
1360 /* Just put in some sanity check. I think there is a bug in the 1360 /* Just put in some sanity check. I think there is a bug in the
1361 * above with some objects have zero speed, and thus the player 1361 * above with some objects have zero speed, and thus the player
1362 * getting permanently paralyzed. 1362 * getting permanently paralyzed.
1363 */ 1363 */
1404 * trigger this here and get hit by own missile - and will be own enemy. 1404 * trigger this here and get hit by own missile - and will be own enemy.
1405 * Victim then is his own enemy and will start to kill herself (this is 1405 * Victim then is his own enemy and will start to kill herself (this is
1406 * removed) but we have not synced victim and his missile. To avoid senseless 1406 * removed) but we have not synced victim and his missile. To avoid senseless
1407 * action, we avoid hits here 1407 * action, we avoid hits here
1408 */ 1408 */
1409 if ((QUERY_FLAG (victim, FLAG_ALIVE) && trap->speed) && trap->owner != victim) 1409 if ((QUERY_FLAG (victim, FLAG_ALIVE) && trap->has_active_speed ())
1410 && trap->owner != victim)
1410 hit_with_arrow (trap, victim); 1411 hit_with_arrow (trap, victim);
1411 break; 1412 break;
1412 1413
1413 case SPELL_EFFECT: 1414 case SPELL_EFFECT:
1414 apply_spell_effect (trap, victim); 1415 apply_spell_effect (trap, victim);
1852 * literacy rate very useful! -b.t. 1853 * literacy rate very useful! -b.t.
1853 */ 1854 */
1854 if (QUERY_FLAG (op, FLAG_CONFUSED)) 1855 if (QUERY_FLAG (op, FLAG_CONFUSED))
1855 { 1856 {
1856 op->failmsg ("In your confused state you flub the wording of the text!"); 1857 op->failmsg ("In your confused state you flub the wording of the text!");
1857 scroll_failure (op, 0 - random_roll (0, spell->level, op, PREFER_LOW), MAX (spell->stats.sp, spell->stats.grace)); 1858 scroll_failure (op, 0 - random_roll (0, spell->level, op, PREFER_LOW), max (spell->stats.sp, spell->stats.grace));
1858 } 1859 }
1859 else if (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || 1860 else if (QUERY_FLAG (tmp, FLAG_STARTEQUIP) ||
1860 (random_roll (0, 100, op, PREFER_LOW) - (5 * skop->level)) < learn_spell[spell->stats.grace ? op->stats.Wis : op->stats.Int]) 1861 (random_roll (0, 100, op, PREFER_LOW) - (5 * skop->level)) < learn_spell[spell->stats.grace ? op->stats.Wis : op->stats.Int])
1861 { 1862 {
1862 op->statusmsg ("You succeed in learning the spell!", NDI_GREEN); 1863 op->statusmsg ("You succeed in learning the spell!", NDI_GREEN);
2022 op->stats.hp += meal->stats.food / 50; 2023 op->stats.hp += meal->stats.food / 50;
2023 2024
2024 if (op->stats.hp > op->stats.maxhp) 2025 if (op->stats.hp > op->stats.maxhp)
2025 op->stats.hp = op->stats.maxhp; 2026 op->stats.hp = op->stats.maxhp;
2026 2027
2027 op->stats.food = MIN (999, op->stats.food + meal->stats.food); 2028 op->stats.food = min (999, op->stats.food + meal->stats.food);
2028 2029
2029 /*LOG(llevDebug, "-> player: %d, flesh: %d\n", op->level, meal->level); */ 2030 /*LOG(llevDebug, "-> player: %d, flesh: %d\n", op->level, meal->level); */
2030 2031
2031 /* on to the interesting part: chances for adding resistance */ 2032 /* on to the interesting part: chances for adding resistance */
2032 for (i = 0; i < NROFATTACKS; i++) 2033 for (i = 0; i < NROFATTACKS; i++)
2042 2043
2043 /* monster bonus increases with level, because high-level 2044 /* monster bonus increases with level, because high-level
2044 flesh is too rare */ 2045 flesh is too rare */
2045 mbonus = op->level * 20. / ((double) settings.max_level); 2046 mbonus = op->level * 20. / ((double) settings.max_level);
2046 2047
2047 chance = (((double) MIN (op->level + bonus, meal->level + bonus + mbonus)) * 100. / 2048 chance = (((double)min (op->level + bonus, meal->level + bonus + mbonus)) * 100. /
2048 ((double) settings.max_level)) - skin->resist[i]; 2049 ((double)settings.max_level)) - skin->resist[i];
2049 2050
2050 if (chance >= 0.) 2051 if (chance >= 0.)
2051 chance += 1.; 2052 chance += 1.;
2052 else 2053 else
2053 chance = (chance < -12) ? 0. : 1. / pow (2., -chance); 2054 chance = (chance < -12) ? 0. : 1. / pow (2., -chance);
2054 2055
2055 /* chance is proportional to amount of resistance (max. 50) */ 2056 /* chance is proportional to amount of resistance (max. 50) */
2056 chance *= ((double) (MIN (meal->resist[i], 50))) / 50.; 2057 chance *= ((double)(min (meal->resist[i], 50))) / 50.;
2057 2058
2058 /* doubled chance for resistance of ability-focus */ 2059 /* doubled chance for resistance of ability-focus */
2059 if (i == abil->stats.exp) 2060 if (i == abil->stats.exp)
2060 chance = MIN (100., chance * 2.); 2061 chance = min (100., chance * 2.);
2061 2062
2062 /* now make the throw and save all winners (Don't insert luck bonus here!) */ 2063 /* now make the throw and save all winners (Don't insert luck bonus here!) */
2063 if (rndm (10000) < (unsigned int) (chance * 100)) 2064 if (rndm (10000) < (unsigned int)(chance * 100))
2064 { 2065 {
2065 atnr_winner[winners] = i; 2066 atnr_winner[winners] = i;
2066 winners++; 2067 winners++;
2067 } 2068 }
2068 2069
2278 * 2279 *
2279 * Note: a owner in a 2 way exit is saved as the owner's name 2280 * Note: a owner in a 2 way exit is saved as the owner's name
2280 * in the field exit->name cause the field exit->owner doesn't 2281 * in the field exit->name cause the field exit->owner doesn't
2281 * survive in the swapping (in fact the whole exit doesn't survive). 2282 * survive in the swapping (in fact the whole exit doesn't survive).
2282 */ 2283 */
2283int 2284static int
2284is_legal_2ways_exit (object *op, object *exit) 2285is_legal_2ways_exit (object *op, object *exit)
2285{ 2286{
2286 if (exit->stats.exp != 1) 2287 if (exit->stats.exp != 1)
2287 return 1; /*This is not a 2 way, so it is legal */ 2288 return 1; /*This is not a 2 way, so it is legal */
2288 2289
2451} 2452}
2452 2453
2453/** 2454/**
2454 * This function generates a cursed effect for cursed lamps and torches. 2455 * This function generates a cursed effect for cursed lamps and torches.
2455 */ 2456 */
2457static void
2456void player_apply_lamp_cursed_effect (object *who, object *op) 2458player_apply_lamp_cursed_effect (object *who, object *op)
2457{ 2459{
2458 if (op->level) 2460 if (op->level)
2459 { 2461 {
2460 who->failmsg (format ( 2462 who->failmsg (format (
2461 "The %s was cursed, it explodes in a big fireball!", 2463 "The %s was cursed, it explodes in a big fireball!",
2476 * Apply for players and lamps 2478 * Apply for players and lamps
2477 * 2479 *
2478 * who - the player 2480 * who - the player
2479 * op - the lamp 2481 * op - the lamp
2480 */ 2482 */
2483static void
2481void player_apply_lamp (object *who, object *op) 2484player_apply_lamp (object *who, object *op)
2482{ 2485{
2483 bool switch_on = op->glow_radius ? false : true; 2486 bool switch_on = op->glow_radius ? false : true;
2484 2487
2485 if (switch_on) 2488 if (switch_on)
2486 { 2489 {
3186#define CANNOT_REMOVE_CURSED \ 3189#define CANNOT_REMOVE_CURSED \
3187 "H<You cannot remove cursed or damned items, you first have to remove the curse. " \ 3190 "H<You cannot remove cursed or damned items, you first have to remove the curse. " \
3188 "Praying over an altar, scrolls of remove curse/damnation, " \ 3191 "Praying over an altar, scrolls of remove curse/damnation, " \
3189 "priests or even other players might help.>" 3192 "priests or even other players might help.>"
3190 3193
3191int 3194static int
3192unapply_for_ob (object *who, object *op, int aflags) 3195unapply_for_ob (object *who, object *op, int aflags)
3193{ 3196{
3194 if (op->is_range ()) 3197 if (op->is_range ())
3195 for (object *tmp = who->inv; tmp; tmp = tmp->below) 3198 for (object *tmp = who->inv; tmp; tmp = tmp->below)
3196 if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->is_range ()) 3199 if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->is_range ())
3760 3763
3761 if (object *pl = op->visible_to ()) 3764 if (object *pl = op->visible_to ())
3762 esrv_send_item (pl, op); 3765 esrv_send_item (pl, op);
3763 3766
3764 return 0; 3767 return 0;
3765}
3766
3767int
3768monster_apply_special (object *who, object *op, int aflags)
3769{
3770 if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED))
3771 return 1;
3772
3773 return apply_special (who, op, aflags);
3774} 3768}
3775 3769
3776/** 3770/**
3777 * Map was just loaded, handle op's initialisation. 3771 * Map was just loaded, handle op's initialisation.
3778 * 3772 *

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines