… | |
… | |
250 | "spell_cause_rabies", /* 204 */ |
250 | "spell_cause_rabies", /* 204 */ |
251 | "spell_glyph", /* 205 */ |
251 | "spell_glyph", /* 205 */ |
252 | NULL |
252 | NULL |
253 | }; |
253 | }; |
254 | |
254 | |
255 | extern int arch_init; |
255 | extern bool loading_arch; |
256 | |
256 | |
257 | /* This function checks the object after it has been loaded (when we |
257 | /* This function checks the object after it has been loaded (when we |
258 | * get the 'end' in the input stream). This function can be used to |
258 | * get the 'end' in the input stream). This function can be used to |
259 | * deal with legacy objects where fields may have changed. It can also be used |
259 | * deal with legacy objects where fields may have changed. It can also be used |
260 | * to check for objects to make sure there are no common errors. |
260 | * to check for objects to make sure there are no common errors. |
… | |
… | |
289 | /* only do these when program is first run - a bit |
289 | /* only do these when program is first run - a bit |
290 | * excessive to do this at every run - most of this is |
290 | * excessive to do this at every run - most of this is |
291 | * really just to catch any errors - program will still run, but |
291 | * really just to catch any errors - program will still run, but |
292 | * not in the ideal fashion. |
292 | * not in the ideal fashion. |
293 | */ |
293 | */ |
294 | if ((op->type == WEAPON || op->type == BOW) && arch_init) |
294 | if ((op->type == WEAPON || op->type == BOW) && loading_arch) |
295 | { |
295 | { |
296 | if (!op->skill) |
296 | if (!op->skill) |
297 | LOG (llevError, "Weapon %s lacks a skill.\n", op->debug_desc ()); |
297 | LOG (llevError, "Weapon %s lacks a skill.\n", op->debug_desc ()); |
298 | else if ((!strcmp (op->skill, "one handed weapons") && op->body_info[1] != -1) || |
298 | else if ((!strcmp (op->skill, "one handed weapons") && op->body_info[1] != -1) || |
299 | (!strcmp (op->skill, "two handed weapons") && op->body_info[1] != -2)) |
299 | (!strcmp (op->skill, "two handed weapons") && op->body_info[1] != -2)) |
… | |
… | |
340 | } |
340 | } |
341 | |
341 | |
342 | /* Old spellcasting object - need to load in the appropiate object */ |
342 | /* Old spellcasting object - need to load in the appropiate object */ |
343 | if ((op->type == ROD || op->type == WAND || op->type == SCROLL || op->type == HORN || op->type == FIREWALL || |
343 | if ((op->type == ROD || op->type == WAND || op->type == SCROLL || op->type == HORN || op->type == FIREWALL || |
344 | /* POTIONS and ALTARS don't always cast spells, but if they do, update them */ |
344 | /* POTIONS and ALTARS don't always cast spells, but if they do, update them */ |
345 | ((op->type == POTION || op->type == ALTAR) && op->stats.sp)) && !op->inv && !arch_init) |
345 | ((op->type == POTION || op->type == ALTAR) && op->stats.sp)) && !op->inv && !loading_arch) |
346 | { |
346 | { |
347 | /* Fireall is bizarre in that spell type was stored in dam. Rest are 'normal' |
347 | /* Fireall is bizarre in that spell type was stored in dam. Rest are 'normal' |
348 | * in that spell was stored in sp. |
348 | * in that spell was stored in sp. |
349 | */ |
349 | */ |
350 | object *tmp = get_archetype (spell_mapping[op->type == FIREWALL ? op->stats.dam : op->stats.sp]); |
350 | object *tmp = get_archetype (spell_mapping[op->type == FIREWALL ? op->stats.dam : op->stats.sp]); |
351 | insert_ob_in_ob (tmp, op); |
351 | insert_ob_in_ob (tmp, op); |
352 | op->randomitems = NULL; /* So another spell isn't created for this object */ |
352 | op->randomitems = NULL; /* So another spell isn't created for this object */ |
353 | } |
353 | } |
354 | |
354 | |
355 | /* spellbooks & runes use slaying. But not to arch name, but to spell name */ |
355 | /* spellbooks & runes use slaying. But not to arch name, but to spell name */ |
356 | if ((op->type == SPELLBOOK || op->type == RUNE) && op->slaying && !op->inv && !arch_init) |
356 | if ((op->type == SPELLBOOK || op->type == RUNE) && op->slaying && !op->inv && !loading_arch) |
357 | { |
357 | { |
358 | object *tmp = get_archetype_by_object_name (op->slaying); |
358 | object *tmp = get_archetype_by_object_name (op->slaying); |
359 | insert_ob_in_ob (tmp, op); |
359 | insert_ob_in_ob (tmp, op); |
360 | op->randomitems = NULL; /* So another spell isn't created for this object */ |
360 | op->randomitems = NULL; /* So another spell isn't created for this object */ |
361 | /* without this, value is all screwed up */ |
361 | /* without this, value is all screwed up */ |
… | |
… | |
409 | |
409 | |
410 | static void |
410 | static void |
411 | set_move (MoveType &mt, const char *str) |
411 | set_move (MoveType &mt, const char *str) |
412 | { |
412 | { |
413 | static const struct flagstr { |
413 | static const struct flagstr { |
414 | char *name; |
414 | const char *name; |
415 | MoveType flags; |
415 | MoveType flags; |
416 | } move_flags[] = { |
416 | } move_flags[] = { |
417 | { "walk" , MOVE_WALK }, |
417 | { "walk" , MOVE_WALK }, |
418 | { "flying" , MOVE_FLY_LOW | MOVE_FLY_HIGH }, |
418 | { "flying" , MOVE_FLY_LOW | MOVE_FLY_HIGH }, |
419 | { "fly_low" , MOVE_FLY_LOW }, |
419 | { "fly_low" , MOVE_FLY_LOW }, |
… | |
… | |
551 | } |
551 | } |
552 | } |
552 | } |
553 | continue; |
553 | continue; |
554 | |
554 | |
555 | case KW_other_arch: |
555 | case KW_other_arch: |
|
|
556 | other_arch = |
|
|
557 | loading_arch |
|
|
558 | ? archetype::get (f.get_str ()) |
556 | other_arch = archetype::find (f.get_str ()); |
559 | : archetype::find (f.get_str ()); |
|
|
560 | |
|
|
561 | if (!other_arch) |
|
|
562 | LOG (llevError, "%s uses unknown other_arch '%s'.\n", debug_desc (), f.get_str ()); |
557 | break; |
563 | break; |
558 | |
564 | |
559 | case KW_animation: |
565 | case KW_animation: |
560 | { |
566 | { |
561 | CLEAR_FLAG (this, FLAG_ANIMATE); |
567 | CLEAR_FLAG (this, FLAG_ANIMATE); |
… | |
… | |
587 | move_slow |= MOVE_WALK; |
593 | move_slow |= MOVE_WALK; |
588 | f.get (move_slow_penalty); |
594 | f.get (move_slow_penalty); |
589 | break; |
595 | break; |
590 | |
596 | |
591 | case KW_face: |
597 | case KW_face: |
592 | face = &new_faces[FindFace (f.get_str (), 0)]; |
598 | face = face_find (f.get_str ()); |
593 | break; |
599 | break; |
594 | |
600 | |
595 | case KW_x: f.get (x); break; |
601 | case KW_x: f.get (x); break; |
596 | case KW_y: f.get (y); break; |
602 | case KW_y: f.get (y); break; |
597 | |
603 | |
… | |
… | |
878 | case KW_glow_radius: f.get (glow_radius); break; |
884 | case KW_glow_radius: f.get (glow_radius); break; |
879 | case KW_weapontype: f.get (weapontype); break; |
885 | case KW_weapontype: f.get (weapontype); break; |
880 | case KW_tooltype: f.get (tooltype); break; |
886 | case KW_tooltype: f.get (tooltype); break; |
881 | case KW_casting_time: f.get (casting_time); break; |
887 | case KW_casting_time: f.get (casting_time); break; |
882 | case KW_elevation: f.get (elevation); break; |
888 | case KW_elevation: f.get (elevation); break; |
883 | case KW_smoothlevel: f.get (smoothlevel); break; |
889 | case KW_smoothlevel: f.get (smoothlevel); smoothlevel = clamp (smoothlevel, 0, 255); break; |
884 | case KW_client_type: f.get (client_type); break; |
890 | case KW_client_type: f.get (client_type); break; |
885 | case KW_duration: f.get (duration); break; |
891 | case KW_duration: f.get (duration); break; |
886 | case KW_range: f.get (range); break; |
892 | case KW_range: f.get (range); break; |
887 | case KW_range_modifier: f.get (range_modifier); break; |
893 | case KW_range_modifier: f.get (range_modifier); break; |
888 | case KW_dam_modifier: f.get (dam_modifier); break; |
894 | case KW_dam_modifier: f.get (dam_modifier); break; |
… | |
… | |
908 | case KW_connected: |
914 | case KW_connected: |
909 | add_button_link (this, map, f.get_sint32 ()); |
915 | add_button_link (this, map, f.get_sint32 ()); |
910 | break; |
916 | break; |
911 | |
917 | |
912 | case KW_randomitems: |
918 | case KW_randomitems: |
913 | randomitems = find_treasurelist (f.get_str ()); |
919 | if (f.get_str ()) |
|
|
920 | { |
|
|
921 | randomitems = |
|
|
922 | loading_arch |
|
|
923 | ? treasurelist::get (f.get_str ()) |
|
|
924 | : treasurelist::find (f.get_str ()); |
|
|
925 | |
914 | //if (!randomitems) |
926 | if (!randomitems) |
915 | // LOG (llevError, "%s uses unknown randomitems '%s'.\n", debug_desc (), f.get_str ()); |
927 | LOG (llevError, "%s uses unknown randomitems '%s'.\n", debug_desc (), f.get_str ()); |
|
|
928 | } |
916 | break; |
929 | break; |
917 | |
930 | |
918 | case KW_msg: |
931 | case KW_msg: |
919 | f.get_ml (KW_endmsg, msg); |
932 | f.get_ml (KW_endmsg, msg); |
920 | //TODO: allow longer messages |
933 | //TODO: allow longer messages |
… | |
… | |
941 | break; |
954 | break; |
942 | |
955 | |
943 | case KW_end: |
956 | case KW_end: |
944 | check_loaded_object (this); |
957 | check_loaded_object (this); |
945 | |
958 | |
946 | if (!arch_init) |
959 | if (!loading_arch) |
947 | instantiate (); |
960 | instantiate (); |
948 | |
961 | |
949 | f.next (); |
962 | f.next (); |
950 | return true; |
963 | return true; |
951 | |
964 | |
… | |
… | |
980 | assert (arch); //D maybe use exception handling of sorts? |
993 | assert (arch); //D maybe use exception handling of sorts? |
981 | |
994 | |
982 | object *op = object::create (); |
995 | object *op = object::create (); |
983 | |
996 | |
984 | op->map = map; |
997 | op->map = map; |
985 | op->arch = arch; |
|
|
986 | arch->clone.copy_to (op); |
998 | arch->clone.copy_to (op); |
987 | // copy_to activates, this should be fixed properly |
999 | // copy_to activates, this should be fixed properly |
988 | op->deactivate (); |
1000 | op->deactivate (); |
989 | |
1001 | |
990 | if (!op->parse_kv (f)) |
1002 | if (!op->parse_kv (f)) |
991 | { |
1003 | { |
992 | delete op; |
1004 | op->destroy (true); |
993 | return 0; |
1005 | return 0; |
994 | } |
1006 | } |
995 | |
1007 | |
996 | return op; |
1008 | return op; |
997 | } |
1009 | } |
… | |
… | |
1243 | f.put (KW_msg, KW_endmsg, op->msg); |
1255 | f.put (KW_msg, KW_endmsg, op->msg); |
1244 | if (op->lore != tmp->lore) |
1256 | if (op->lore != tmp->lore) |
1245 | f.put (KW_lore, KW_endlore, op->lore); |
1257 | f.put (KW_lore, KW_endlore, op->lore); |
1246 | |
1258 | |
1247 | CMP_OUT (other_arch); |
1259 | CMP_OUT (other_arch); |
1248 | CMP_OUT (face); |
1260 | |
|
|
1261 | if (op->face != tmp->face) f.put (KW_face, op->face ? &faces [op->face] : 0); |
1249 | |
1262 | |
1250 | if (op->animation_id != tmp->animation_id) |
1263 | if (op->animation_id != tmp->animation_id) |
1251 | if (op->animation_id) |
1264 | if (op->animation_id) |
1252 | { |
1265 | { |
1253 | f.put (KW_animation, animations[GET_ANIM_ID (op)].name); |
1266 | f.put (KW_animation, animations[GET_ANIM_ID (op)].name); |