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.43 by root, Tue Dec 19 05:12:52 2006 UTC vs.
Revision 1.50 by root, Thu Dec 21 23:37:05 2006 UTC

195apply_potion (object *op, object *tmp) 195apply_potion (object *op, object *tmp)
196{ 196{
197 int got_one = 0, i; 197 int got_one = 0, i;
198 object *force = 0, *floor = 0; 198 object *force = 0, *floor = 0;
199 199
200 floor = get_map_ob (op->map, op->x, op->y); 200 floor = GET_MAP_OB (op->map, op->x, op->y);
201 201
202 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) 202 if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE)
203 { 203 {
204 if (op->type == PLAYER) 204 if (op->type == PLAYER)
205 new_draw_info (NDI_UNIQUE, 0, op, "Gods prevent you from using this here, it's sacred ground!"); 205 new_draw_info (NDI_UNIQUE, 0, op, "Gods prevent you from using this here, it's sacred ground!");
1046 if (op->container != sack) 1046 if (op->container != sack)
1047 { 1047 {
1048 /* it's closed OR some player has opened it */ 1048 /* it's closed OR some player has opened it */
1049 if (QUERY_FLAG (sack, FLAG_APPLIED)) 1049 if (QUERY_FLAG (sack, FLAG_APPLIED))
1050 { 1050 {
1051 for (tmp = get_map_ob (sack->map, sack->x, sack->y); tmp && tmp->container != sack; tmp = tmp->above); 1051 for (tmp = GET_MAP_OB (sack->map, sack->x, sack->y); tmp && tmp->container != sack; tmp = tmp->above);
1052 if (tmp) 1052 if (tmp)
1053 { 1053 {
1054 /* some other player have opened it */ 1054 /* some other player have opened it */
1055 new_draw_info_format (NDI_UNIQUE, 0, op, "%s is already occupied.", query_name (sack)); 1055 new_draw_info_format (NDI_UNIQUE, 0, op, "%s is already occupied.", query_name (sack));
1056 return 1; 1056 return 1;
1120 tmp = find_key (op, op, sack); 1120 tmp = find_key (op, op, sack);
1121 if (tmp) 1121 if (tmp)
1122 { 1122 {
1123 sprintf (buf, "You unlock %s with %s.", query_name (sack), query_name (tmp)); 1123 sprintf (buf, "You unlock %s with %s.", query_name (sack), query_name (tmp));
1124 SET_FLAG (sack, FLAG_APPLIED); 1124 SET_FLAG (sack, FLAG_APPLIED);
1125
1125 if (sack->env == NULL) 1126 if (sack->env == NULL)
1126 { /* if it's on ground,open it also */ 1127 { /* if it's on ground,open it also */
1127 new_draw_info (NDI_UNIQUE, 0, op, buf); 1128 new_draw_info (NDI_UNIQUE, 0, op, buf);
1128 apply_container (op, sack); 1129 apply_container (op, sack);
1129 return 1; 1130 return 1;
1130 } 1131 }
1131 } 1132 }
1132 else 1133 else
1133 {
1134 sprintf (buf, "You don't have the key to unlock %s.", query_name (sack)); 1134 sprintf (buf, "You don't have the key to unlock %s.", query_name (sack));
1135 }
1136 } 1135 }
1137 else 1136 else
1138 { 1137 {
1139 sprintf (buf, "You readied %s.", query_name (sack)); 1138 sprintf (buf, "You readied %s.", query_name (sack));
1140 SET_FLAG (sack, FLAG_APPLIED); 1139 SET_FLAG (sack, FLAG_APPLIED);
1140
1141 if (sack->env == NULL) 1141 if (sack->env == NULL)
1142 { /* if it's on ground,open it also */ 1142 { /* if it's on ground,open it also */
1143 new_draw_info (NDI_UNIQUE, 0, op, buf); 1143 new_draw_info (NDI_UNIQUE, 0, op, buf);
1144 apply_container (op, sack); 1144 apply_container (op, sack);
1145 return 1; 1145 return 1;
1148 } 1148 }
1149 1149
1150 new_draw_info (NDI_UNIQUE, 0, op, buf); 1150 new_draw_info (NDI_UNIQUE, 0, op, buf);
1151 1151
1152 if (op->contr) 1152 if (op->contr)
1153 op->contr->socket->floorbox_update (); 1153 op->contr->ns->floorbox_update ();
1154 1154
1155 return 1; 1155 return 1;
1156} 1156}
1157 1157
1158/** 1158/**
1795 1795
1796 /* If in a container, update how it looks */ 1796 /* If in a container, update how it looks */
1797 if (tmp->env) 1797 if (tmp->env)
1798 esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); 1798 esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp);
1799 else 1799 else
1800 op->contr->socket->floorbox_update (); 1800 op->contr->ns->floorbox_update ();
1801 } 1801 }
1802 1802
1803 change_exp (op, exp_gain, skill_ob->skill, 0); 1803 change_exp (op, exp_gain, skill_ob->skill, 0);
1804 SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ 1804 SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */
1805 } 1805 }
1958 identify (tmp); 1958 identify (tmp);
1959 1959
1960 if (tmp->env) 1960 if (tmp->env)
1961 esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp); 1961 esrv_update_item (UPD_FLAGS | UPD_NAME, op, tmp);
1962 else 1962 else
1963 op->contr->socket->floorbox_update (); 1963 op->contr->ns->floorbox_update ();
1964 } 1964 }
1965 1965
1966 /* I removed the check for special_prayer_mark here - it didn't make 1966 /* I removed the check for special_prayer_mark here - it didn't make
1967 * a lot of sense - special prayers are not found in spellbooks, and 1967 * a lot of sense - special prayers are not found in spellbooks, and
1968 * if the player doesn't know the spell, doesn't make a lot of sense that 1968 * if the player doesn't know the spell, doesn't make a lot of sense that
2448/** 2448/**
2449 * This fonction return true if the exit is not a 2 ways one or it is 2 ways, valid exit. 2449 * This fonction return true if the exit is not a 2 ways one or it is 2 ways, valid exit.
2450 * A valid 2 way exit means: 2450 * A valid 2 way exit means:
2451 * -You can come back (there is another exit at the other side) 2451 * -You can come back (there is another exit at the other side)
2452 * -You are 2452 * -You are
2453 * ° the owner of the exit 2453 * ° the owner of the exit
2454 * ° or in the same party as the owner 2454 * ° or in the same party as the owner
2455 * 2455 *
2456 * Note: a owner in a 2 way exit is saved as the owner's name 2456 * Note: a owner in a 2 way exit is saved as the owner's name
2457 * in the field exit->name cause the field exit->owner doesn't 2457 * in the field exit->name cause the field exit->owner doesn't
2458 * survive in the swapping (in fact the whole exit doesn't survive). 2458 * survive in the swapping (in fact the whole exit doesn't survive).
2459 */ 2459 */
2476 exitmap = ready_map_name (EXIT_PATH (exit), MAP_PLAYER_UNIQUE); 2476 exitmap = ready_map_name (EXIT_PATH (exit), MAP_PLAYER_UNIQUE);
2477 else 2477 else
2478 exitmap = ready_map_name (EXIT_PATH (exit), 0); 2478 exitmap = ready_map_name (EXIT_PATH (exit), 0);
2479 if (exitmap) 2479 if (exitmap)
2480 { 2480 {
2481 tmp = get_map_ob (exitmap, EXIT_X (exit), EXIT_Y (exit)); 2481 tmp = GET_MAP_OB (exitmap, EXIT_X (exit), EXIT_Y (exit));
2482 if (!tmp) 2482 if (!tmp)
2483 return 0; 2483 return 0;
2484 for ((tmp = get_map_ob (exitmap, EXIT_X (exit), EXIT_Y (exit))); tmp; tmp = tmp->above) 2484 for ((tmp = GET_MAP_OB (exitmap, EXIT_X (exit), EXIT_Y (exit))); tmp; tmp = tmp->above)
2485 { 2485 {
2486 if (tmp->type != EXIT) 2486 if (tmp->type != EXIT)
2487 continue; /*Not an exit */ 2487 continue; /*Not an exit */
2488 if (!EXIT_PATH (tmp)) 2488 if (!EXIT_PATH (tmp))
2489 continue; /*Not a valid exit */ 2489 continue; /*Not a valid exit */
3727 if (m == NULL) 3727 if (m == NULL)
3728 return; 3728 return;
3729 3729
3730 for (x = 0; x < MAP_WIDTH (m); x++) 3730 for (x = 0; x < MAP_WIDTH (m); x++)
3731 for (y = 0; y < MAP_HEIGHT (m); y++) 3731 for (y = 0; y < MAP_HEIGHT (m); y++)
3732 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = above) 3732 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = above)
3733 { 3733 {
3734 above = tmp->above; 3734 above = tmp->above;
3735 3735
3736 if (tmp->inv) 3736 if (tmp->inv)
3737 { 3737 {
3810 } 3810 }
3811 } 3811 }
3812 3812
3813 for (x = 0; x < MAP_WIDTH (m); x++) 3813 for (x = 0; x < MAP_WIDTH (m); x++)
3814 for (y = 0; y < MAP_HEIGHT (m); y++) 3814 for (y = 0; y < MAP_HEIGHT (m); y++)
3815 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) 3815 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above)
3816 if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL)) 3816 if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL))
3817 check_trigger (tmp, tmp->above); 3817 check_trigger (tmp, tmp->above);
3818} 3818}
3819 3819
3820/** 3820/**
3850 { 3850 {
3851 force->resist[i] = food->resist[i] / 2; 3851 force->resist[i] = food->resist[i] / 2;
3852 did_one = 1; 3852 did_one = 1;
3853 } 3853 }
3854 } 3854 }
3855
3855 if (did_one) 3856 if (did_one)
3856 { 3857 {
3857 force->speed = 0.1; 3858 force->speed = 0.1;
3858 update_ob_speed (force); 3859 update_ob_speed (force);
3859 /* bigger morsel of food = longer effect time */ 3860 /* bigger morsel of food = longer effect time */
3860 force->stats.food = food->stats.food / 5; 3861 force->duration = food->stats.food / 5;
3861 SET_FLAG (force, FLAG_IS_USED_UP);
3862 SET_FLAG (force, FLAG_APPLIED); 3862 SET_FLAG (force, FLAG_APPLIED);
3863 change_abil (who, force); 3863 change_abil (who, force);
3864 insert_ob_in_ob (force, who); 3864 insert_ob_in_ob (force, who);
3865 } 3865 }
3866 else 3866 else
3901 } 3901 }
3902 } 3902 }
3903 fix_player (who); 3903 fix_player (who);
3904} 3904}
3905 3905
3906
3907/** 3906/**
3908 * Designed primarily to light torches/lanterns/etc. 3907 * Designed primarily to light torches/lanterns/etc.
3909 * Also burns up burnable material too. First object in the inventory is 3908 * Also burns up burnable material too. First object in the inventory is
3910 * the selected object to "burn". -b.t. 3909 * the selected object to "burn". -b.t.
3911 */ 3910 */
3912
3913void 3911void
3914apply_lighter (object *who, object *lighter) 3912apply_lighter (object *who, object *lighter)
3915{ 3913{
3916 object *item; 3914 object *item;
3917 int is_player_env = 0; 3915 int is_player_env = 0;
3918 char item_name[MAX_BUF];
3919 3916
3920 item = find_marked_object (who); 3917 item = find_marked_object (who);
3921 if (item) 3918 if (item)
3922 { 3919 {
3923 if (lighter->last_eat && lighter->stats.food) 3920 if (lighter->last_eat && lighter->stats.food)
3941 else if (lighter->last_eat) 3938 else if (lighter->last_eat)
3942 { /* no charges left in lighter */ 3939 { /* no charges left in lighter */
3943 new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with a used up %s.", &item->name, &lighter->name); 3940 new_draw_info_format (NDI_UNIQUE, 0, who, "You attempt to light the %s with a used up %s.", &item->name, &lighter->name);
3944 return; 3941 return;
3945 } 3942 }
3943
3946 /* Perhaps we should split what we are trying to light on fire? 3944 /* Perhaps we should split what we are trying to light on fire?
3947 * I can't see many times when you would want to light multiple 3945 * I can't see many times when you would want to light multiple
3948 * objects at once. 3946 * objects at once.
3949 */ 3947 */
3950 /* If the item is destroyed, we don't have a valid pointer to the 3948
3951 * name object, so make a copy so the message we print out makes
3952 * some sense.
3953 */
3954 strcpy (item_name, item->name);
3955 if (who == is_player_inv (item)) 3949 if (who == item->in_player ())
3956 is_player_env = 1; 3950 is_player_env = 1;
3957 3951
3958 save_throw_object (item, AT_FIRE, who); 3952 save_throw_object (item, AT_FIRE, who);
3959 /* Change to check count and not freed, since the object pointer 3953
3960 * may have gotten recycled
3961 */
3962 if (item->destroyed ()) 3954 if (item->destroyed ())
3963 { 3955 {
3964 new_draw_info_format (NDI_UNIQUE, 0, who, "You light the %s with the %s.", &item_name, &lighter->name); 3956 new_draw_info_format (NDI_UNIQUE, 0, who, "You light the %s with the %s.", &item->name, &lighter->name);
3965 /* Need to update the player so that the players glow radius 3957 /* Need to update the player so that the players glow radius
3966 * gets changed. 3958 * gets changed.
3967 */ 3959 */
3968 if (is_player_env) 3960 if (is_player_env)
3969 fix_player (who); 3961 fix_player (who);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines