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

Comparing deliantra/server/server/time.C (file contents):
Revision 1.84 by root, Thu Jan 8 04:35:05 2009 UTC vs.
Revision 1.95 by root, Mon Oct 26 11:31:39 2009 UTC

3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your option) any later version. 11 * option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
20 * 21 *
21 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 23 */
23 24
24/* 25/*
599 600
600 // restore original wc, dam, attacktype and slaying 601 // restore original wc, dam, attacktype and slaying
601 op->stats.wc = op->stats.sp; 602 op->stats.wc = op->stats.sp;
602 op->stats.dam = op->stats.hp; 603 op->stats.dam = op->stats.hp;
603 op->attacktype = op->stats.grace; 604 op->attacktype = op->stats.grace;
605 op->slaying = op->custom_name;
604 606
605 if (op->spellarg)
606 {
607 op->slaying = op->spellarg;
608 free (op->spellarg);
609 op->spellarg = 0;
610 }
611 else
612 op->slaying = 0;
613
614 /* Reset these to zero, so that object::can_merge will work properly */ 607 /* Reset these to defaults, so that object::can_merge will work properly */
615 op->spellarg = NULL; 608 op->custom_name = 0;
616 op->stats.sp = 0; 609 op->stats.sp = 0;
617 op->stats.hp = 0; 610 op->stats.hp = 0;
618 op->stats.grace = 0; 611 op->stats.grace = 0;
619 op->level = 0; 612 op->level = 0;
620 op->face = op->arch->face; 613 op->face = op->arch->face;
621 op->owner = NULL; /* So that stopped arrows will be saved */ 614 op->owner = 0;
615
622 update_object (op, UP_OBJ_CHANGE); 616 update_object (op, UP_OBJ_CHANGE);
617
623 return op; 618 return op;
624} 619}
625 620
626/* stop_arrow() - what to do when a non-living flying object 621/* stop_arrow() - what to do when a non-living flying object
627 * has to stop. Sept 96 - I added in thrown object code in 622 * has to stop. Sept 96 - I added in thrown object code in
816 return; 811 return;
817 } 812 }
818 813
819 /* update object image for new facing */ 814 /* update object image for new facing */
820 /* many thrown objects *don't* have more than one face */ 815 /* many thrown objects *don't* have more than one face */
821 if (GET_ANIM_ID (op)) 816 if (op->has_anim ())
822 SET_ANIMATION (op, op->direction); 817 op->set_anim_frame (op->direction);
823 } /* object is reflected */ 818 } /* object is reflected */
824 } /* object ran into a wall */ 819 } /* object ran into a wall */
825 820
826 /* decrease the speed as it flies. 0.05 means a standard bow will shoot 821 /* decrease the speed as it flies. 0.05 means a standard bow will shoot
827 * about 17 squares. Tune as needed. 822 * about 17 squares. Tune as needed.
856 851
857 op->remove (); 852 op->remove ();
858 for (i = 0; i < op->stats.food; i++) 853 for (i = 0; i < op->stats.food; i++)
859 { 854 {
860 object *tmp = arch_to_object (op->other_arch); 855 object *tmp = arch_to_object (op->other_arch);
861
862 if (op->type == LAMP)
863 tmp->stats.food = op->stats.food - 1;
864 856
865 tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ 857 tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */
866 858
867 if (env) 859 if (env)
868 env->insert (tmp); 860 env->insert (tmp);
1238 { 1230 {
1239 /* remove an old force with a slaying field == op->name */ 1231 /* remove an old force with a slaying field == op->name */
1240 if (object *force = tmp->force_find (op->name)) 1232 if (object *force = tmp->force_find (op->name))
1241 force->destroy (); 1233 force->destroy ();
1242 1234
1243 if (!tmp->force_find (op->slaying)) 1235 if (op->slaying && !tmp->force_find (op->slaying))
1244 { 1236 {
1245 tmp->force_add (op->slaying, op->stats.food); 1237 tmp->force_add (op->slaying, op->stats.food);
1246 1238
1247 if (op->msg) 1239 if (op->msg)
1248 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, tmp, op->msg); 1240 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, tmp, op->msg);
1269{ 1261{
1270 op->set_speed (0); 1262 op->set_speed (0);
1271 cfperl_mapscript_activate (op, true, op, 0); 1263 cfperl_mapscript_activate (op, true, op, 0);
1272} 1264}
1273 1265
1266void move_lamp (object *op)
1267{
1268 // if the lamp/torch is off, we should disable it.
1269 if (!op->glow_radius)
1270 {
1271 op->set_speed (0);
1272 return;
1273 }
1274 else
1275 {
1276 // check whether the face might need to be updated
1277 // (currently this is needed to have already switched on torches
1278 // on maps, as they just set the glow_radius in the archetype)
1279 if (op->other_arch
1280 && (
1281 (op->flag [FLAG_ANIMATE] != op->other_arch->flag [FLAG_ANIMATE])
1282 || (op->flag [FLAG_ANIMATE]
1283 ? (op->animation_id != op->other_arch->animation_id)
1284 : (op->face != op->other_arch->face))
1285 ))
1286 get_animation_from_arch (op, op->other_arch);
1287 }
1288
1289 // lamps and torches on maps don't use up their fuel
1290 if (op->is_on_map ())
1291 return;
1292
1293 if (op->stats.food > 0)
1294 {
1295 op->stats.food--;
1296 return;
1297 }
1298
1299 apply_lamp (op, false);
1300}
1301
1274void 1302void
1275process_object (object *op) 1303process_object (object *op)
1276{ 1304{
1277 if (expect_false (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE))) 1305 if (expect_false (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)))
1278 return; 1306 return;
1454 break; 1482 break;
1455 1483
1456 case MAPSCRIPT: 1484 case MAPSCRIPT:
1457 move_mapscript (op); 1485 move_mapscript (op);
1458 break; 1486 break;
1459 }
1460}
1461 1487
1488 case LAMP:
1489 case TORCH:
1490 move_lamp (op);
1491 break;
1492 }
1493}
1494

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines