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.81 by root, Mon Sep 29 10:31:32 2008 UTC vs.
Revision 1.86 by elmex, Tue Jan 13 12:07:42 2009 UTC

98 return; 98 return;
99 99
100 if (GENERATE_SPEED (gen) && rndm (0, GENERATE_SPEED (gen) - 1)) 100 if (GENERATE_SPEED (gen) && rndm (0, GENERATE_SPEED (gen) - 1))
101 return; 101 return;
102 102
103 // sleeping generators won't generate, this will make monsters like
104 // centipedes not generate more centipedes when being asleep.
105 if (gen->flag [FLAG_SLEEP])
106 return;
107
103 object *op; 108 object *op;
104 int dir; 109 int dir;
105 110
106 if (QUERY_FLAG (gen, FLAG_CONTENT_ON_GEN)) 111 if (QUERY_FLAG (gen, FLAG_CONTENT_ON_GEN))
107 { 112 {
149 create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty); 154 create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty);
150 155
151 return; 156 return;
152 } 157 }
153 158
154 op->destroy (true); 159 op->destroy ();
155} 160}
156 161
157void 162void
158remove_force (object *op) 163remove_force (object *op)
159{ 164{
171 CLEAR_FLAG (op, FLAG_APPLIED); 176 CLEAR_FLAG (op, FLAG_APPLIED);
172 change_abil (op->env, op); 177 change_abil (op->env, op);
173 op->env->update_stats (); 178 op->env->update_stats ();
174 } 179 }
175 180
176 op->destroy (true); 181 op->destroy ();
177} 182}
178 183
179void 184void
180remove_blindness (object *op) 185remove_blindness (object *op)
181{ 186{
188 { 193 {
189 change_abil (op->env, op); 194 change_abil (op->env, op);
190 op->env->update_stats (); 195 op->env->update_stats ();
191 } 196 }
192 197
193 op->destroy (true); 198 op->destroy ();
194} 199}
195 200
196void 201void
197poison_more (object *op) 202poison_more (object *op)
198{ 203{
199 if (op->env == NULL || !QUERY_FLAG (op->env, FLAG_ALIVE) || op->env->stats.hp < 0) 204 if (op->env == NULL || !QUERY_FLAG (op->env, FLAG_ALIVE) || op->env->stats.hp < 0)
200 { 205 {
201 op->destroy (true); 206 op->destroy ();
202 return; 207 return;
203 } 208 }
204 209
205 if (op->stats.food == 1) 210 if (op->stats.food == 1)
206 { 211 {
212 CLEAR_FLAG (op, FLAG_APPLIED); 217 CLEAR_FLAG (op, FLAG_APPLIED);
213 op->env->update_stats (); 218 op->env->update_stats ();
214 new_draw_info (NDI_UNIQUE, 0, op->env, "You feel much better now."); 219 new_draw_info (NDI_UNIQUE, 0, op->env, "You feel much better now.");
215 } 220 }
216 221
217 op->destroy (true); 222 op->destroy ();
218 return; 223 return;
219 } 224 }
220 225
221 if (op->env->type == PLAYER) 226 if (op->env->type == PLAYER)
222 { 227 {
437 if (op->stats.sp == 1) 442 if (op->stats.sp == 1)
438 { 443 {
439 if (detected && last == 0) 444 if (detected && last == 0)
440 { 445 {
441 op->value = 1; 446 op->value = 1;
442 push_button (op); 447 push_button (op, tmp);
443 } 448 }
444 449
445 if (!detected && last == 1) 450 if (!detected && last == 1)
446 { 451 {
447 op->value = 0; 452 op->value = 0;
448 push_button (op); 453 push_button (op, tmp);
449 } 454 }
450 } 455 }
451 else 456 else
452 { /* in this case, we unset buttons */ 457 { /* in this case, we unset buttons */
453 if (detected && last == 1) 458 if (detected && last == 1)
454 { 459 {
455 op->value = 0; 460 op->value = 0;
456 push_button (op); 461 push_button (op, tmp);
457 } 462 }
458 463
459 if (!detected && last == 0) 464 if (!detected && last == 0)
460 { 465 {
461 op->value = 1; 466 op->value = 1;
462 push_button (op); 467 push_button (op, tmp);
463 } 468 }
464 } 469 }
465} 470}
466 471
467void 472void
543 548
544 if (payload == NULL) 549 if (payload == NULL)
545 return NULL; 550 return NULL;
546 551
547 payload->remove (); 552 payload->remove ();
548 op->destroy (true); 553 op->destroy ();
549 return payload; 554 return payload;
550 } 555 }
551 556
552 case ARROW: 557 case ARROW:
553 if (op->has_active_speed ()) 558 if (op->has_active_speed ())
580fix_stopped_arrow (object *op) 585fix_stopped_arrow (object *op)
581{ 586{
582 if (rndm (0, 99) < op->stats.food) 587 if (rndm (0, 99) < op->stats.food)
583 { 588 {
584 /* Small chance of breaking */ 589 /* Small chance of breaking */
585 op->destroy (true); 590 op->destroy ();
586 return NULL; 591 return NULL;
587 } 592 }
588 593
589 op->set_speed (0); 594 op->set_speed (0);
590 op->direction = 0; 595 op->direction = 0;
636 // replace this by straightforward drop to ground? 641 // replace this by straightforward drop to ground?
637 object *payload = op->inv; 642 object *payload = op->inv;
638 643
639 payload->owner = 0; 644 payload->owner = 0;
640 insert_ob_in_map (payload, op->map, payload, 0); 645 insert_ob_in_map (payload, op->map, payload, 0);
641 op->destroy (true); 646 op->destroy ();
642 } 647 }
643 else 648 else
644 { 649 {
645 op = fix_stopped_arrow (op); 650 op = fix_stopped_arrow (op);
646 651
657 int was_reflected; 662 int was_reflected;
658 663
659 if (!op->map) 664 if (!op->map)
660 { 665 {
661 LOG (llevError, "BUG: Arrow had no map.\n"); 666 LOG (llevError, "BUG: Arrow had no map.\n");
662 op->destroy (true); 667 op->destroy ();
663 return; 668 return;
664 } 669 }
665 670
666 /* we need to stop thrown objects at some point. Like here. */ 671 /* we need to stop thrown objects at some point. Like here. */
667 if (op->type == THROWN_OBJ) 672 if (op->type == THROWN_OBJ)
674 * bomb code, but there are potential other cases where that could happen, 679 * bomb code, but there are potential other cases where that could happen,
675 * and it is easy enough to clean it up here. 680 * and it is easy enough to clean it up here.
676 */ 681 */
677 if (!op->inv) 682 if (!op->inv)
678 { 683 {
679 op->destroy (true); 684 op->destroy ();
680 return; 685 return;
681 } 686 }
682 687
683 if (op->last_sp-- < 0) 688 if (op->last_sp-- < 0)
684 { 689 {
852 op->remove (); 857 op->remove ();
853 for (i = 0; i < op->stats.food; i++) 858 for (i = 0; i < op->stats.food; i++)
854 { 859 {
855 object *tmp = arch_to_object (op->other_arch); 860 object *tmp = arch_to_object (op->other_arch);
856 861
857 if (op->type == LAMP)
858 tmp->stats.food = op->stats.food - 1;
859
860 tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ 862 tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */
861 863
862 if (env) 864 if (env)
863 env->insert (tmp); 865 env->insert (tmp);
864 else 866 else
865 { 867 {
866 j = find_first_free_spot (tmp, op->map, op->x, op->y); 868 j = find_first_free_spot (tmp, op->map, op->x, op->y);
867 if (j < 0) /* No free spot */ 869 if (j < 0) /* No free spot */
868 tmp->destroy (true); 870 tmp->destroy ();
869 else 871 else
870 { 872 {
871 mapxy pos (op); pos.move (j); 873 mapxy pos (op); pos.move (j);
872 874
873 if (pos.normalise ()) 875 if (pos.normalise ())
874 pos.insert (tmp, op); 876 pos.insert (tmp, op);
875 } 877 }
876 } 878 }
877 } 879 }
878 880
879 op->destroy (true); 881 op->destroy ();
880} 882}
881 883
882void 884void
883move_teleporter (object *op) 885move_teleporter (object *op)
884{ 886{
921 else if (EXIT_X (head) || EXIT_Y (head)) 923 else if (EXIT_X (head) || EXIT_Y (head))
922 { 924 {
923 if (out_of_map (head->map, EXIT_X (head), EXIT_Y (head))) 925 if (out_of_map (head->map, EXIT_X (head), EXIT_Y (head)))
924 { 926 {
925 LOG (llevError, "Removed illegal teleporter.\n"); 927 LOG (llevError, "Removed illegal teleporter.\n");
926 head->destroy (true); 928 head->destroy ();
927 return; 929 return;
928 } 930 }
929 931
930 if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp))) 932 if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp)))
931 return; 933 return;
1125 for (tmp = op->above; tmp; tmp = tmp->above) 1127 for (tmp = op->above; tmp; tmp = tmp->above)
1126 { 1128 {
1127 if (op->other_arch->archname == tmp->arch->archname) 1129 if (op->other_arch->archname == tmp->arch->archname)
1128 { 1130 {
1129 if (op->level <= 0) 1131 if (op->level <= 0)
1130 tmp->destroy (true); 1132 tmp->destroy ();
1131 else 1133 else
1132 { 1134 {
1133 uint64 new_nrof = (uint64) tmp->nrof * op->level; 1135 uint64 new_nrof = (uint64) tmp->nrof * op->level;
1134 1136
1135 if (new_nrof >= 1UL << 31) 1137 if (new_nrof >= 1UL << 31)
1231{ 1233{
1232 if (object *tmp = op->ms ().player ()) 1234 if (object *tmp = op->ms ().player ())
1233 { 1235 {
1234 /* remove an old force with a slaying field == op->name */ 1236 /* remove an old force with a slaying field == op->name */
1235 if (object *force = tmp->force_find (op->name)) 1237 if (object *force = tmp->force_find (op->name))
1236 force->destroy (true); 1238 force->destroy ();
1237 1239
1238 if (!tmp->force_find (op->slaying)) 1240 if (!tmp->force_find (op->slaying))
1239 { 1241 {
1240 tmp->force_add (op->slaying, op->stats.food); 1242 tmp->force_add (op->slaying, op->stats.food);
1241 1243
1247 op->stats.hp--; 1249 op->stats.hp--;
1248 1250
1249 if (op->stats.hp == 0) 1251 if (op->stats.hp == 0)
1250 { 1252 {
1251 /* marker expires--granted mark number limit */ 1253 /* marker expires--granted mark number limit */
1252 op->destroy (true); 1254 op->destroy ();
1253 return; 1255 return;
1254 } 1256 }
1255 } 1257 }
1256 } 1258 }
1257 } 1259 }
1260}
1261
1262// mapscript objects activate themselves (only) then their timer fires
1263// TODO: maybe they should simply trigger the link like any other object?
1264void
1265move_mapscript (object *op)
1266{
1267 op->set_speed (0);
1268 cfperl_mapscript_activate (op, true, op, 0);
1269}
1270
1271void move_lamp (object *op)
1272{
1273 // if the lamp/torch is off, we should disable it.
1274 if (!op->glow_radius)
1275 {
1276 op->set_speed (0);
1277 return;
1278 }
1279 else
1280 {
1281 // check whether the face might needs to be updated
1282 // (currently this is needed to have already switched on torches
1283 // on maps, as they just set the glow_radius in the archetype)
1284 if (op->other_arch
1285 && (
1286 op->flag [FLAG_ANIMATE]
1287 ? (op->animation_id != op->other_arch->animation_id)
1288 : (op->face != op->other_arch->face)
1289 ))
1290 get_animation_from_arch (op, op->other_arch);
1291 }
1292
1293 // lamps and torches auf maps don't use up their fuel
1294 if (op->is_on_map ())
1295 return;
1296
1297 if (op->stats.food > 0)
1298 {
1299 op->stats.food--;
1300 return;
1301 }
1302
1303 apply_lamp (op, false);
1258} 1304}
1259 1305
1260void 1306void
1261process_object (object *op) 1307process_object (object *op)
1262{ 1308{
1436 1482
1437 case PLAYER: 1483 case PLAYER:
1438 // players have their own speed-management, so undo the --speed_left 1484 // players have their own speed-management, so undo the --speed_left
1439 ++op->speed_left; 1485 ++op->speed_left;
1440 break; 1486 break;
1441 }
1442}
1443 1487
1488 case MAPSCRIPT:
1489 move_mapscript (op);
1490 break;
1491
1492 case LAMP:
1493 case TORCH:
1494 move_lamp (op);
1495 break;
1496 }
1497}
1498

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines