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

Comparing deliantra/server/server/spell_util.C (file contents):
Revision 1.128 by root, Wed Nov 16 23:42:03 2016 UTC vs.
Revision 1.131 by root, Sat Nov 17 23:40:04 2018 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001 Mark Wedel & Crossfire Development Team 6 * Copyright (©) 2001 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 7 * Copyright (©) 1992 Frank Tore Johansen
7 * 8 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 9 * Deliantra is free software: you can redistribute it and/or modify it under
362} 363}
363 364
364/* Returns true if it is ok to put spell *op on the space/may provided. 365/* Returns true if it is ok to put spell *op on the space/may provided.
365 * immune_stop is basically the attacktype of the spell (why 366 * immune_stop is basically the attacktype of the spell (why
366 * passed as a different value, not sure of). If immune_stop 367 * passed as a different value, not sure of). If immune_stop
367 * has the AT_MAGIC bit set, and there is a counterwall 368 * has the AT_MAGIC bit set, and there is a counterwall
368 * on the space, the object doesn't get placed. if immune stop 369 * on the space, the object doesn't get placed. if immune stop
369 * does not have AT_MAGIC, then counterwalls do not effect the spell. 370 * does not have AT_MAGIC, then counterwalls do not effect the spell.
370 */ 371 */
371int 372int
372ok_to_put_more (maptile *m, sint16 x, sint16 y, object *op, int immune_stop) 373ok_to_put_more (maptile *m, sint16 x, sint16 y, object *op, int immune_stop)
544 tmp = op; 545 tmp = op;
545 } 546 }
546 else 547 else
547 { 548 {
548 maptile *m = op->map; 549 maptile *m = op->map;
549 sint16 x = op->x + freearr_x[dir]; 550 sint16 x = op->x + DIRX (dir);
550 sint16 y = op->y + freearr_y[dir]; 551 sint16 y = op->y + DIRY (dir);
551 552
552 tmp = xy_normalise (m, x, y) 553 tmp = xy_normalise (m, x, y)
553 ? m->at (x, y).player () 554 ? m->at (x, y).player ()
554 : 0; 555 : 0;
555 } 556 }
586 if (exclude && exclude->type) 587 if (exclude && exclude->type)
587 owner_type = exclude->type; 588 owner_type = exclude->type;
588 589
589 for (i = rndm (1, 8); i < max; i++) 590 for (i = rndm (1, 8); i < max; i++)
590 { 591 {
591 nx = x + freearr_x[i]; 592 nx = x + DIRX (i);
592 ny = y + freearr_y[i]; 593 ny = y + DIRY (i);
593 mp = m; 594 mp = m;
594 mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny); 595 mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny);
595 if (mflags & (P_OUT_OF_MAP | P_BLOCKSVIEW)) 596 if (mflags & (P_OUT_OF_MAP | P_BLOCKSVIEW))
596 continue; 597 continue;
597 598
623 624
624 if ((at = archetype::find (monstername)) == NULL) 625 if ((at = archetype::find (monstername)) == NULL)
625 return; 626 return;
626 627
627 /* find a free square nearby 628 /* find a free square nearby
628 * first we check the closest square for free squares 629 * first we check the closest square for free squares
629 */ 630 */
630 631
631 dir = find_first_free_spot (at, op->map, op->x, op->y); 632 dir = find_first_free_spot (at, op->map, op->x, op->y);
632 if (dir != -1) 633 if (dir != -1)
633 { 634 {
636 */ 637 */
637 //TODO: use expand_tail + ... 638 //TODO: use expand_tail + ...
638 while (at != NULL) 639 while (at != NULL)
639 { 640 {
640 tmp = at->instance (); 641 tmp = at->instance ();
641 tmp->x = op->x + freearr_x[dir] + at->x; 642 tmp->x = op->x + DIRX (dir) + at->x;
642 tmp->y = op->y + freearr_y[dir] + at->y; 643 tmp->y = op->y + DIRY (dir) + at->y;
643 tmp->map = op->map; 644 tmp->map = op->map;
644 if (head) 645 if (head)
645 { 646 {
646 tmp->head = head; 647 tmp->head = head;
647 prev->more = tmp; 648 prev->more = tmp;
659 create_treasure (head->randomitems, head, GT_INVISIBLE, op->map->difficulty, 0); 660 create_treasure (head->randomitems, head, GT_INVISIBLE, op->map->difficulty, 0);
660 661
661 insert_ob_in_map (head, op->map, op, 0); 662 insert_ob_in_map (head, op->map, op, 0);
662 663
663 /* thought it'd be cool to insert a burnout, too. */ 664 /* thought it'd be cool to insert a burnout, too. */
664 op->map->insert (archetype::get (shstr_burnout), op->x + freearr_x[dir], op->y + freearr_y[dir], op); 665 op->map->insert (archetype::get (shstr_burnout), op->x + DIRX (dir), op->y + DIRY (dir), op);
665 } 666 }
666} 667}
667 668
668/* peterm: function which summons hostile monsters and 669/* peterm: function which summons hostile monsters and
669 * places them in nearby squares. 670 * places them in nearby squares.
720 { AT_PARALYZE, 9}, 721 { AT_PARALYZE, 9},
721 { AT_FEAR, 10}, 722 { AT_FEAR, 10},
722}; 723};
723 724
724/* shuffle_attack: peterm 725/* shuffle_attack: peterm
725 * This routine shuffles the attack of op to one of the 726 * This routine shuffles the attack of op to one of the
726 * ones in the list. It does this at random. It also 727 * ones in the list. It does this at random. It also
727 * chooses a face appropriate to the attack that is 728 * chooses a face appropriate to the attack that is
728 * being committed by that square at the moment. 729 * being committed by that square at the moment.
729 * right now it's being used by color spray and create pool of 730 * right now it's being used by color spray and create pool of
730 * chaos. 731 * chaos.
731 * This could really be a better implementation - the 732 * This could really be a better implementation - the
732 * faces and attacktypes above are hardcoded, which is never 733 * faces and attacktypes above are hardcoded, which is never
733 * good. The faces refer to faces in the animation sequence. 734 * good. The faces refer to faces in the animation sequence.
945 { 946 {
946 LOG (llevError, "cast_spell: null caster object passed\n"); 947 LOG (llevError, "cast_spell: null caster object passed\n");
947 return 0; 948 return 0;
948 } 949 }
949 950
950 /* if caster is a spell casting object, this normally shouldn't be 951 /* if caster is a spell casting object, this normally shouldn't be
951 * an issue, because they don't have any spellpaths set up. 952 * an issue, because they don't have any spellpaths set up.
952 */ 953 */
953 if (caster->path_denied & spell_ob->path_attuned && !caster->flag [FLAG_WIZCAST]) 954 if (caster->path_denied & spell_ob->path_attuned && !caster->flag [FLAG_WIZCAST])
954 { 955 {
955 op->failmsg ("That spell path is denied to you."); 956 op->failmsg ("That spell path is denied to you.");
957 } 958 }
958 959
959 object *skill = 0; 960 object *skill = 0;
960 961
961 /* if it is a player casting the spell, and they are really casting it 962 /* if it is a player casting the spell, and they are really casting it
962 * (vs it coming from a wand, scroll, or whatever else), do some 963 * (vs it coming from a wand, scroll, or whatever else), do some
963 * checks. We let monsters do special things - eg, they 964 * checks. We let monsters do special things - eg, they
964 * don't need the SKILL, BYpass level checks, etc. The monster function 965 * don't need the SKILL, BYpass level checks, etc. The monster function
965 * should take care of that. 966 * should take care of that.
966 * Remove the wiz check here and move it further down - some spells 967 * Remove the wiz check here and move it further down - some spells
967 * need to have the right skill pointer passed, so we need to 968 * need to have the right skill pointer passed, so we need to
999 } 1000 }
1000 1001
1001 if (spell_ob->level > caster_level) 1002 if (spell_ob->level > caster_level)
1002 { 1003 {
1003 op->failmsgf ("You lack enough skill to cast that spell! " 1004 op->failmsgf ("You lack enough skill to cast that spell! "
1004 "H<Your effective cast level is %d%s, but level %d is required.>", 1005 "H<Your effective cast level is %d%s, but level %d is required.>",
1005 caster_level, msg, spell_ob->level); 1006 caster_level, msg, spell_ob->level);
1006 if (!op->is_wiz ()) 1007 if (!op->is_wiz ())
1007 return 0; 1008 return 0;
1008 } 1009 }
1009 } 1010 }
1105 1106
1106 // undo the flood protection from earlier 1107 // undo the flood protection from earlier
1107 op->speed_left += 4 * op->speed; // ~0.5s on failure 1108 op->speed_left += 4 * op->speed; // ~0.5s on failure
1108 1109
1109 /* Take into account how long it takes to cast the spell. 1110 /* Take into account how long it takes to cast the spell.
1110 * if the player is casting it, then we use the time in 1111 * if the player is casting it, then we use the time in
1111 * the spell object. If it is a spell object, have it 1112 * the spell object. If it is a spell object, have it
1112 * take two ticks. Things that cast spells on the players 1113 * take two ticks. Things that cast spells on the players
1113 * behalf (eg, altars, and whatever else) shouldn't cost 1114 * behalf (eg, altars, and whatever else) shouldn't cost
1114 * the player any time. 1115 * the player any time.
1115 * Ignore casting time for firewalls 1116 * Ignore casting time for firewalls

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines