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.198 by root, Wed Oct 7 22:18:51 2009 UTC vs.
Revision 1.199 by sf-marcmagus, Sun Oct 11 05:43:35 2009 UTC

3801eat_special_food (object *who, object *food) 3801eat_special_food (object *who, object *food)
3802{ 3802{
3803 object *force; 3803 object *force;
3804 int i, did_one = 0; 3804 int i, did_one = 0;
3805 3805
3806 force = get_archetype (FORCE_NAME); 3806 char buf[64];
3807 snprintf (buf, sizeof(buf), "sp_food_%s", &food->title);
3808 shstr key (buf);
3807 3809
3808 for (i = 0; i < NUM_STATS; i++)
3809 if (sint8 k = food->stats.stat (i))
3810 {
3811 force->stats.stat (i) = k;
3812 did_one = 1;
3813 }
3814
3815 /* check if we can protect the eater */
3816 for (i = 0; i < NROFATTACKS; i++)
3817 {
3818 if (food->resist[i] > 0)
3819 {
3820 force->resist[i] = food->resist[i] / 2;
3821 did_one = 1;
3822 }
3823 }
3824
3825 if (did_one)
3826 {
3827 force->set_speed (0.1);
3828 /* bigger morsel of food = longer effect time */ 3810 /* bigger morsel of food = longer effect time */
3829 force->duration = food->stats.food / 5; 3811 int duration = TIME2TICK (food->stats.food);
3830 SET_FLAG (force, FLAG_APPLIED); 3812
3831 change_abil (who, force); 3813 if (force = who->force_find (key))
3832 insert_ob_in_ob (force, who); 3814 {
3815 if (duration > abs (force->speed_left / force->speed))
3816 {
3817 new_draw_info_format (NDI_UNIQUE, 0, who, "More magical force spreads through you. H<The effect will last for about %.10g more seconds.>", TICK2TIME (duration));
3818 force->force_set_timer (duration);
3819 }
3820 else
3821 new_draw_info (NDI_UNIQUE, 0, who, "It had no additional effect.");
3822
3823 return;
3833 } 3824 }
3834 else 3825 else
3826 {
3827 force = who->force_add (key, duration);
3828 force->name = key;
3829
3830 /* check if the food affects a stat */
3831 for (i = 0; i < NUM_STATS; i++)
3832 if (sint8 k = food->stats.stat (i))
3833 {
3834 force->stats.stat (i) = k;
3835 did_one = 1;
3836 }
3837
3838 /* check if we can protect the eater */
3839 for (i = 0; i < NROFATTACKS; i++)
3840 {
3841 if (food->resist[i] > 0)
3842 {
3843 force->resist[i] = food->resist[i];
3844 did_one = 1;
3845 }
3846 }
3847
3848 if (did_one)
3849 {
3850 new_draw_info_format (NDI_UNIQUE, 0, who, "You are suffused with magical force. H<The effect will last for about %.10g seconds.>", TICK2TIME (duration));
3851
3852 /* make the force take effect and report effects to user */
3853 change_abil (who, force);
3854 }
3855 else
3835 force->destroy (); 3856 force->destroy ();
3857 }
3836 3858
3837 /* check for hp, sp change */ 3859 /* check for hp, sp change */
3838 if (food->stats.hp != 0) 3860 if (food->stats.hp != 0)
3839 { 3861 {
3840 if (QUERY_FLAG (food, FLAG_CURSED)) 3862 if (QUERY_FLAG (food, FLAG_CURSED))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines