1 /*-------------------------------------------------------------------------------
2 
3 BARONY
4 File: entity_shared.cpp
5 Desc: functions to be shared between editor.exe and barony.exe
6 
7 Copyright 2013-2016 (c) Turning Wheel LLC, all rights reserved.
8 See LICENSE for details.
9 
10 -------------------------------------------------------------------------------*/
11 
12 
13 #include "entity.hpp"
14 
15 
checkSpriteType(Sint32 sprite)16 int checkSpriteType(Sint32 sprite)
17 {
18 	switch ( sprite )
19 	{
20 	case 71:
21 	case 70:
22 	case 62:
23 	case 48:
24 	case 36:
25 	case 35:
26 	case 30:
27 	case 27:
28 	case 10:
29 	case 83:
30 	case 84:
31 	case 85:
32 	case 86:
33 	case 87:
34 	case 88:
35 	case 89:
36 	case 90:
37 	case 91:
38 	case 92:
39 	case 93:
40 	case 94:
41 	case 95:
42 	case 75:
43 	case 76:
44 	case 77:
45 	// to test case 37
46 	case 37:
47 	case 78:
48 	case 79:
49 	case 80:
50 	case 81:
51 	case 82:
52 	case 163:
53 	case 164:
54 	case 165:
55 	case 166:
56 		//monsters
57 		return 1;
58 		break;
59 	case 21:
60 		//chest
61 		return 2;
62 		break;
63 	case 8:
64 		//items
65 		return 3;
66 		break;
67 	case 97:
68 		//summon trap
69 		return 4;
70 		break;
71 	case 106:
72 		//power crystal
73 		return 5;
74 		break;
75 	case 115:
76 		// lever timer
77 		return 6;
78 	case 102:
79 	case 103:
80 	case 104:
81 	case 105:
82 		//boulder traps
83 		return 7;
84 		break;
85 	case 116:
86 		//pedestal
87 		return 8;
88 		break;
89 	case 118:
90 		//teleporter
91 		return 9;
92 		break;
93 	case 119:
94 		//ceiling tile model
95 		return 10;
96 		break;
97 	case 120:
98 		//magic ceiling trap
99 		return 11;
100 		break;
101 	case 121:
102 	case 122:
103 	case 123:
104 	case 124:
105 	case 125:
106 	case 60:
107 		// general furniture/misc.
108 		return 12;
109 		break;
110 	case 127:
111 		// floor decoration
112 		return 13;
113 		break;
114 	case 130:
115 		// sound source
116 		return 14;
117 	case 131:
118 		// light source
119 		return 15;
120 	case 132:
121 		// text source
122 		return 16;
123 	case 133:
124 		// signal modifier
125 		return 17;
126 	case 161:
127 		// custom exit
128 		return 18;
129 	case 59:
130 		// table
131 		return 19;
132 	case 162:
133 		// readablebook
134 		return 20;
135 	case 2:
136 	case 3:
137 		return 21;
138 	case 19:
139 	case 20:
140 	case 113:
141 	case 114:
142 		return 22;
143 	case 1:
144 		return 23;
145 		break;
146 	default:
147 		return 0;
148 		break;
149 	}
150 
151 	return 0;
152 }
153 
154 char itemNameStrings[NUM_ITEM_STRINGS][32] =
155 {
156 	"NULL",
157 	"random_item",
158 	"wooden_shield",
159 	"quarterstaff",
160 	"bronze_sword",
161 	"bronze_mace",
162 	"bronze_axe",
163 	"bronze_shield",
164 	"sling",
165 	"iron_spear",
166 	"iron_sword",
167 	"iron_mace",
168 	"iron_axe",
169 	"iron_shield",
170 	"shortbow",
171 	"steel_halberd",
172 	"steel_sword",
173 	"steel_mace",
174 	"steel_axe",
175 	"steel_shield",
176 	"steel_shield_resistance",
177 	"crossbow",
178 	"gloves",
179 	"gloves_dexterity",
180 	"bracers",
181 	"bracers_constitution",
182 	"gauntlets",
183 	"gauntlets_strength",
184 	"cloak",
185 	"cloak_magicreflection",
186 	"cloak_invisibility",
187 	"cloak_protection",
188 	"leather_boots",
189 	"leather_boots_speed",
190 	"iron_boots",
191 	"iron_boots_waterwalking",
192 	"steel_boots",
193 	"steel_boots_levitation",
194 	"steel_boots_feather",
195 	"leather_breastpiece",
196 	"iron_breastpiece",
197 	"steel_breastpiece",
198 	"hat_phrygian",
199 	"hat_hood",
200 	"hat_wizard",
201 	"hat_jester",
202 	"leather_helm",
203 	"iron_helm",
204 	"steel_helm",
205 	"amulet_sexchange",
206 	"amulet_lifesaving",
207 	"amulet_waterbreathing",
208 	"amulet_magicreflection",
209 	"amulet_strangulation",
210 	"amulet_poisonresistance",
211 	"potion_water",
212 	"potion_booze",
213 	"potion_juice",
214 	"potion_sickness",
215 	"potion_confusion",
216 	"potion_extrahealing",
217 	"potion_healing",
218 	"potion_cureailment",
219 	"potion_blindness",
220 	"potion_restoremagic",
221 	"potion_invisibility",
222 	"potion_levitation",
223 	"potion_speed",
224 	"potion_acid",
225 	"potion_paralysis",
226 	"scroll_mail",
227 	"scroll_identify",
228 	"scroll_light",
229 	"scroll_blank",
230 	"scroll_enchantweapon",
231 	"scroll_enchantarmor",
232 	"scroll_removecurse",
233 	"scroll_fire",
234 	"scroll_food",
235 	"scroll_magicmapping",
236 	"scroll_repair",
237 	"scroll_destroyarmor",
238 	"scroll_teleportation",
239 	"scroll_summon",
240 	"magicstaff_light",
241 	"magicstaff_digging",
242 	"magicstaff_locking",
243 	"magicstaff_magicmissile",
244 	"magicstaff_opening",
245 	"magicstaff_slow",
246 	"magicstaff_cold",
247 	"magicstaff_fire",
248 	"magicstaff_lightning",
249 	"magicstaff_sleep",
250 	"ring_adornment",
251 	"ring_slowdigestion",
252 	"ring_protection",
253 	"ring_warning",
254 	"ring_strength",
255 	"ring_constitution",
256 	"ring_invisibility",
257 	"ring_magicresistance",
258 	"ring_conflict",
259 	"ring_levitation",
260 	"ring_regeneration",
261 	"ring_teleportation",
262 	"spellbook_forcebolt",
263 	"spellbook_magicmissile",
264 	"spellbook_cold",
265 	"spellbook_fireball",
266 	"spellbook_light",
267 	"spellbook_removecurse",
268 	"spellbook_lightning",
269 	"spellbook_identify",
270 	"spellbook_magicmapping",
271 	"spellbook_sleep",
272 	"spellbook_confuse",
273 	"spellbook_slow",
274 	"spellbook_opening",
275 	"spellbook_locking",
276 	"spellbook_levitation",
277 	"spellbook_invisibility",
278 	"spellbook_teleportation",
279 	"spellbook_healing",
280 	"spellbook_extrahealing",
281 	"spellbook_cureailment",
282 	"spellbook_dig",
283 	"gem_rock",
284 	"gem_luck",
285 	"gem_garnet",
286 	"gem_ruby",
287 	"gem_jacinth",
288 	"gem_amber",
289 	"gem_citrine",
290 	"gem_jade",
291 	"gem_emerald",
292 	"gem_sapphire",
293 	"gem_aquamarine",
294 	"gem_amethyst",
295 	"gem_fluorite",
296 	"gem_opal",
297 	"gem_diamond",
298 	"gem_jetstone",
299 	"gem_obsidian",
300 	"gem_glass",
301 	"tool_pickaxe",
302 	"tool_tinopener",
303 	"tool_mirror",
304 	"tool_lockpick",
305 	"tool_skeletonkey",
306 	"tool_torch",
307 	"tool_lantern",
308 	"tool_blindfold",
309 	"tool_towel",
310 	"tool_glasses",
311 	"tool_beartrap",
312 	"food_bread",
313 	"food_creampie",
314 	"food_cheese",
315 	"food_apple",
316 	"food_meat",
317 	"food_fish",
318 	"food_tin",
319 	"readable_book",
320 	"spell_item",
321 	"artifact_sword",
322 	"artifact_mace",
323 	"artifact_spear",
324 	"artifact_axe",
325 	"artifact_bow",
326 	"artifact_breastpiece",
327 	"artifact_helm",
328 	"artifact_boots",
329 	"artifact_cloak",
330 	"artifact_gloves",
331 	"crystal_breastpiece",
332 	"crystal_helm",
333 	"crystal_boots",
334 	"crystal_shield",
335 	"crystal_gloves",
336 	"vampire_doublet",
337 	"wizard_doublet",
338 	"healer_doublet",
339 	"mirror_shield",
340 	"brass_knuckles",
341 	"iron_knuckles",
342 	"spiked_gauntlets",
343 	"food_tomalley",
344 	"tool_crystalshard",
345 	"crystal_sword",
346 	"crystal_spear",
347 	"crystal_battleaxe",
348 	"crystal_mace",
349 	"bronze_tomahawk",
350 	"iron_dagger",
351 	"steel_chakram",
352 	"crystal_shuriken",
353 	"cloak_black",
354 	"magicstaff_stoneblood",
355 	"magicstaff_bleed",
356 	"magicstaff_summon",
357 	"tool_blindfold_focus",
358 	"tool_blindfold_telepathy",
359 	"spellbook_summon",
360 	"spellbook_stoneblood",
361 	"spellbook_bleed",
362 	"spellbook_reflect_magic",
363 	"spellbook_acid_spray",
364 	"spellbook_steal_weapon",
365 	"spellbook_drain_soul",
366 	"spellbook_vampiric_aura",
367 	"spellbook_charm",
368 	"potion_empty",
369 	"artifact_orb_blue",
370 	"artifact_orb_red",
371 	"artifact_orb_purple",
372 	"artifact_orb_green",
373 	"tunic",
374 	"hat_fez",
375 	"magicstaff_charm",
376 	"potion_polymorph",
377 	"food_blood",
378 	"cloak_backpack",
379 	"tool_alembic",
380 	"potion_firestorm",
381 	"potion_icestorm",
382 	"potion_thunderstorm",
383 	"potion_strength",
384 	"suede_boots",
385 	"suede_gloves",
386 	"cloak_silver",
387 	"hat_hood_silver",
388 	"hat_hood_red",
389 	"silver_doublet",
390 	"spellbook_revert_form",
391 	"spellbook_rat_form",
392 	"spellbook_spider_form",
393 	"spellbook_troll_form",
394 	"spellbook_imp_form",
395 	"spellbook_spray_web",
396 	"spellbook_poison",
397 	"spellbook_speed",
398 	"spellbook_fear",
399 	"spellbook_strike",
400 	"spellbook_detect_food",
401 	"spellbook_weakness",
402 	"mask_shaman",
403 	"spellbook_amplify_magic",
404 	"spellbook_shadow_tag",
405 	"spellbook_telepull",
406 	"spellbook_demon_illu",
407 	"spellbook_trolls_blood",
408 	"spellbook_salvage",
409 	"tool_whip",
410 	"spellbook_flutter",
411 	"spellbook_dash",
412 	"spellbook_self_polymorph",
413 	"spellbook_9",
414 	"spellbook_10",
415 	"magicstaff_poison",
416 	"tool_metal_scrap",
417 	"tool_magic_scrap",
418 	"tool_tinkering_kit",
419 	"tool_sentrybot",
420 	"tool_repairkit",
421 	"tool_fire_bomb",
422 	"tool_sleep_bomb",
423 	"tool_freeze_bomb",
424 	"tool_teleport_bomb",
425 	"tool_gyrobot",
426 	"tool_spellbot",
427 	"tool_decoy",
428 	"tool_dummybot",
429 	"machinist_apron",
430 	"enchanted_feather",
431 	"punisher_hood",
432 	"scroll_charging",
433 	"quiver_sharp",
434 	"quiver_pierce",
435 	"quiver_lightweight",
436 	"quiver_fire",
437 	"quiver_heavy",
438 	"quiver_crystal",
439 	"quiver_hunting",
440 	"longbow",
441 	"compound_bow",
442 	"heavy_crossbow",
443 	"boomerang",
444 	"scroll_conjurearrow",
445 	""
446 };
447 
448 char itemStringsByType[10][NUM_ITEM_STRINGS_BY_TYPE][32] =
449 {
450 	{
451 		"NULL",
452 		"random_item",
453 		"hat_phrygian",
454 		"hat_hood",
455 		"hat_wizard",
456 		"hat_jester",
457 		"hat_fez",
458 		"hat_hood_silver",
459 		"hat_hood_red",
460 		"mask_shaman",
461 		"punisher_hood",
462 		"leather_helm",
463 		"iron_helm",
464 		"steel_helm",
465 		"crystal_helm",
466 		"artifact_helm"
467 		""
468 	},
469 	{
470 		"NULL",
471 		"random_item",
472 		"quarterstaff",
473 		"bronze_sword",
474 		"bronze_mace",
475 		"bronze_axe",
476 		"sling",
477 		"iron_spear",
478 		"iron_sword",
479 		"iron_mace",
480 		"iron_axe",
481 		"shortbow",
482 		"steel_halberd",
483 		"steel_sword",
484 		"steel_mace",
485 		"steel_axe",
486 		"crystal_sword",
487 		"crystal_spear",
488 		"crystal_battleaxe",
489 		"crystal_mace",
490 		"crossbow",
491 		"bronze_tomahawk",
492 		"iron_dagger",
493 		"steel_chakram",
494 		"crystal_shuriken",
495 		"boomerang",
496 		"longbow",
497 		"compound_bow",
498 		"heavy_crossbow",
499 		"potion_water",
500 		"potion_booze",
501 		"potion_juice",
502 		"potion_sickness",
503 		"potion_confusion",
504 		"potion_extrahealing",
505 		"potion_healing",
506 		"potion_cureailment",
507 		"potion_blindness",
508 		"potion_restoremagic",
509 		"potion_invisibility",
510 		"potion_levitation",
511 		"potion_speed",
512 		"potion_acid",
513 		"potion_paralysis",
514 		"potion_polymorph",
515 		"potion_firestorm",
516 		"potion_icestorm",
517 		"potion_thunderstorm",
518 		"potion_strength",
519 		"magicstaff_light",
520 		"magicstaff_digging",
521 		"magicstaff_locking",
522 		"magicstaff_magicmissile",
523 		"magicstaff_opening",
524 		"magicstaff_slow",
525 		"magicstaff_cold",
526 		"magicstaff_fire",
527 		"magicstaff_lightning",
528 		"magicstaff_sleep",
529 		"magicstaff_stoneblood",
530 		"magicstaff_bleed",
531 		"magicstaff_summon",
532 		"magicstaff_charm",
533 		"magicstaff_poison",
534 		"spellbook_forcebolt",
535 		"spellbook_magicmissile",
536 		"spellbook_cold",
537 		"spellbook_fireball",
538 		"spellbook_light",
539 		"spellbook_removecurse",
540 		"spellbook_lightning",
541 		"spellbook_identify",
542 		"spellbook_magicmapping",
543 		"spellbook_sleep",
544 		"spellbook_confuse",
545 		"spellbook_slow",
546 		"spellbook_opening",
547 		"spellbook_locking",
548 		"spellbook_levitation",
549 		"spellbook_invisibility",
550 		"spellbook_teleportation",
551 		"spellbook_healing",
552 		"spellbook_extrahealing",
553 		"spellbook_cureailment",
554 		"spellbook_summon",
555 		"spellbook_stoneblood",
556 		"spellbook_bleed",
557 		"spellbook_dig",
558 		"spellbook_reflect_magic",
559 		"spellbook_acid_spray",
560 		"spellbook_steal_weapon",
561 		"spellbook_drain_soul",
562 		"spellbook_vampiric_aura",
563 		"spellbook_charm",
564 		"spellbook_revert_form",
565 		"spellbook_rat_form",
566 		"spellbook_spider_form",
567 		"spellbook_troll_form",
568 		"spellbook_imp_form",
569 		"spellbook_spray_web",
570 		"spellbook_poison",
571 		"spellbook_speed",
572 		"spellbook_fear",
573 		"spellbook_strike",
574 		"spellbook_detect_food",
575 		"spellbook_weakness",
576 		"spellbook_amplify_magic",
577 		"spellbook_shadow_tag",
578 		"spellbook_telepull",
579 		"spellbook_demon_illu",
580 		"spellbook_trolls_blood",
581 		"spellbook_salvage",
582 		"spellbook_flutter",
583 		"spellbook_dash",
584 		"spellbook_self_polymorph",
585 		"spellbook_9",
586 		"spellbook_10",
587 		"tool_whip",
588 		"tool_pickaxe",
589 		"artifact_sword",
590 		"artifact_mace",
591 		"artifact_spear",
592 		"artifact_axe",
593 		"artifact_bow",
594 		"artifact_orb_blue",
595 		"artifact_orb_red",
596 		"artifact_orb_purple",
597 		"artifact_orb_green",
598 		""
599 	},
600 	{
601 		"NULL",
602 		"random_item",
603 		"wooden_shield",
604 		"bronze_shield",
605 		"iron_shield",
606 		"steel_shield",
607 		"steel_shield_resistance",
608 		"crystal_shield",
609 		"mirror_shield",
610 		"tool_torch",
611 		"tool_lantern",
612 		"tool_crystalshard",
613 		"quiver_sharp",
614 		"quiver_pierce",
615 		"quiver_lightweight",
616 		"quiver_fire",
617 		"quiver_heavy",
618 		"quiver_crystal",
619 		"quiver_hunting",
620 		""
621 	},
622 	{
623 		"NULL",
624 		"random_item",
625 		"leather_breastpiece",
626 		"iron_breastpiece",
627 		"steel_breastpiece",
628 		"crystal_breastpiece",
629 		"artifact_breastpiece",
630 		"vampire_doublet",
631 		"wizard_doublet",
632 		"healer_doublet",
633 		"tunic",
634 		"silver_doublet",
635 		"machinist_apron",
636 		""
637 	},
638 	{
639 		"NULL",
640 		"random_item",
641 		"leather_boots",
642 		"leather_boots_speed",
643 		"iron_boots",
644 		"iron_boots_waterwalking",
645 		"steel_boots",
646 		"steel_boots_levitation",
647 		"steel_boots_feather",
648 		"crystal_boots",
649 		"artifact_boots",
650 		"suede_boots",
651 		""
652 	},
653 	{
654 		"NULL",
655 		"random_item",
656 		"ring_adornment",
657 		"ring_slowdigestion",
658 		"ring_protection",
659 		"ring_warning",
660 		"ring_strength",
661 		"ring_constitution",
662 		"ring_invisibility",
663 		"ring_magicresistance",
664 		"ring_conflict",
665 		"ring_levitation",
666 		"ring_regeneration",
667 		"ring_teleportation",
668 		""
669 	},
670 	{
671 		"NULL",
672 		"random_item",
673 		"amulet_sexchange",
674 		"amulet_lifesaving",
675 		"amulet_waterbreathing",
676 		"amulet_magicreflection",
677 		"amulet_strangulation",
678 		"amulet_poisonresistance",
679 		""
680 	},
681 	{
682 		"NULL",
683 		"random_item",
684 		"cloak",
685 		"cloak_black",
686 		"cloak_silver",
687 		"cloak_magicreflection",
688 		"cloak_invisibility",
689 		"cloak_protection",
690 		"artifact_cloak",
691 		"cloak_backpack",
692 		""
693 	},
694 	{
695 		"NULL",
696 		"random_item",
697 		"tool_blindfold",
698 		"tool_glasses",
699 		"tool_blindfold_focus",
700 		"tool_blindfold_telepathy",
701 		""
702 	},
703 	{
704 		"NULL",
705 		"random_item",
706 		"gloves",
707 		"gloves_dexterity",
708 		"bracers",
709 		"bracers_constitution",
710 		"gauntlets",
711 		"gauntlets_strength",
712 		"crystal_gloves",
713 		"artifact_gloves",
714 		"brass_knuckles",
715 		"iron_knuckles",
716 		"spiked_gauntlets",
717 		"suede_gloves",
718 		""
719 	}
720 
721 };
722 
723 char spriteEditorNameStrings[NUM_EDITOR_SPRITES][64] =
724 {
725 	"NULL",
726 	"PLAYER START",
727 	"DOOR (East-West)",
728 	"DOOR (North-South)",
729 	"TORCH (West Wall)",
730 	"TORCH (North Wall)",
731 	"TORCH (East Wall)",
732 	"TORCH (South Wall)",
733 	"ITEM",
734 	"GOLD",
735 	"RANDOM (Dependent on Level)",
736 	"LADDER",
737 	"FIREPLACE",
738 	"Flame Sprite (Not Used)",
739 	"FOUNTAIN",
740 	"SINK",
741 	"Flame Sprite (Not Used)",
742 	"Lever",
743 	"Wire",
744 	"GATE (North-South)",
745 	"GATE (East-West)",
746 	"CHEST",
747 	"NOT USED",
748 	"NOT USED",
749 	"NOT USED",
750 	"NOT USED",
751 	"NOT USED",
752 	"HUMAN",
753 	"NOT USED",
754 	"NOT USED",
755 	"TROLL",
756 	"NOT USED",
757 	"ARROW TRAP",
758 	"PRESSURE PLATE",
759 	"PRESSURE PLATE (Latch On)",
760 	"SHOPKEEPER",
761 	"GOBLIN",
762 	"MINOTAUR SPAWN TRAP",
763 	"BOULDER TRAP",
764 	"HEADSTONE",
765 	"NULL",
766 	"LAVA",
767 	"NOT USED",
768 	"LADDER HOLE",
769 	"BOULDER",
770 	"PORTAL",
771 	"SECRET LADDER",
772 	"NOT USED",
773 	"SPIDER",
774 	"NOT USED",
775 	"NOT USED",
776 	"NOT USED",
777 	"NOT USED",
778 	"NOT USED",
779 	"NOT USED",
780 	"NOT USED",
781 	"NOT USED",
782 	"NOT USED",
783 	"NOT USED",
784 	"TABLE",
785 	"CHAIR",
786 	"DIAMOND PICKAXE",
787 	"LICH",
788 	"END PORTAL",
789 	"SPEAR TRAP",
790 	"MAGIC TRAP",
791 	"WALL BUSTER",
792 	"WALL BUILDER",
793 	"MAGIC BOW",
794 	"MAGIC SPEAR",
795 	"GNOME",
796 	"DEVIL",
797 	"DEVIL TELEPORT LOCATION",
798 	"DEVIL TELEPORT LOCATION",
799 	"DEVIL TELEPORT LOCATION",
800 	"DEMON",
801 	"IMP",
802 	"MINOTAUR",
803 	"SCORPION",
804 	"SLIME",
805 	"SUCCUBUS",
806 	"RAT",
807 	"GHOUL",
808 	"SKELETON",
809 	"KOBOLD",
810 	"SCARAB",
811 	"CRYSTALGOLEM",
812 	"INCUBUS",
813 	"VAMPIRE",
814 	"SHADOW",
815 	"COCKATRICE",
816 	"INSECTOID",
817 	"GOATMAN",
818 	"AUTOMATON",
819 	"LICH ICE",
820 	"LICH FIRE",
821 	"NOT USED",
822 	"SUMMON TRAP",
823 	"CRYSTAL SHARD (West Wall)",
824 	"CRYSTAL SHARD (North Wall)",
825 	"CRYSTAL SHARD (East Wall)",
826 	"CRYSTAL SHARD (South Wall)",
827 	"BOULDER TRAP SINGLE (Roll East)",
828 	"BOULDER TRAP SINGLE (Roll South)",
829 	"BOULDER TRAP SINGLE (Roll West)",
830 	"BOULDER TRAP SINGLE (Roll North)",
831 	"POWER CRYSTAL",
832 	"ARMED BEAR TRAP",
833 	"STALAG-COLUMN",
834 	"STALAGMITE SINGLE",
835 	"STALAGMITE MULTIPLE",
836 	"STALAGTITE SINGLE",
837 	"STALAGTITE MULTIPLE",
838 	"GATE INVERTED (North-South)",
839 	"GATE INVERTED (East-West)",
840 	"LEVER WITH TIMER",
841 	"PEDESTAL",
842 	"MID PORTAL",
843 	"TELEPORTER",
844 	"CEILING TILE MODEL",
845 	"SPELL TRAP CEILING",
846 	"ARCANE CHAIR",
847 	"ARCANE BED",
848 	"BUNK BED",
849 	"COLUMN DECO",
850 	"PODIUM",
851 	"PISTONS",
852 	"DECORATION",
853 	"TELEPORT LOCATION",
854 	"ENDEND PORTAL",
855 	"SOUND SOURCE",
856 	"LIGHT SOURCE",
857 	"TEXT SOURCE",
858 	"SIGNAL TIMER",
859 	"NOT USED",
860 	"NOT USED",
861 	"NOT USED",
862 	"NOT USED",
863 	"NOT USED",
864 	"NOT USED",
865 	"NOT USED",
866 	"NOT USED",
867 	"NOT USED",
868 	"NOT USED",
869 	"NOT USED",
870 	"NOT USED",
871 	"NOT USED",
872 	"NOT USED",
873 	"NOT USED",
874 	"NOT USED",
875 	"NOT USED",
876 	"NOT USED",
877 	"NOT USED",
878 	"NOT USED",
879 	"NOT USED",
880 	"NOT USED",
881 	"NOT USED",
882 	"NOT USED",
883 	"NOT USED",
884 	"NOT USED",
885 	"NOT USED",
886 	"CUSTOM EXIT",
887 	"READABLE BOOK",
888 	"SENTRYBOT",
889 	"SPELLBOT",
890 	"DUMMYBOT",
891 	"GYROBOT",
892 	"UNUSED"
893 };
894 
895 char monsterEditorNameStrings[NUMMONSTERS][16] =
896 {
897 	"nothing",
898 	"human",
899 	"rat",
900 	"goblin",
901 	"slime",
902 	"troll",
903 	"invalid",
904 	"spider",
905 	"ghoul",
906 	"skeleton",
907 	"scorpion",
908 	"imp",
909 	"invalid",
910 	"gnome",
911 	"demon",
912 	"succubus",
913 	"invalid",
914 	"lich",
915 	"minotaur",
916 	"devil",
917 	"shopkeeper",
918 	"kobold",
919 	"scarab",
920 	"crystalgolem",
921 	"incubus",
922 	"vampire",
923 	"shadow",
924 	"cockatrice",
925 	"insectoid",
926 	"goatman",
927 	"automaton",
928 	"lich_ice",
929 	"lich_fire",
930 	"sentrybot",
931 	"spellbot",
932 	"gyrobot",
933 	"dummybot"
934 };
935 
936 char tileEditorNameStrings[NUM_EDITOR_TILES][44] =
937 {
938 	"backdrop.png",
939 	"bback.png",
940 	"bbrick.png",
941 	"greenbrick.png",
942 	"graysquare.png",
943 	"sand.png",
944 	"rock.png",
945 	"arrow.png",
946 	" Smooth Stone Wall.png",
947 	" Wood.png",
948 	" Cobblestone Mine Wall.png",
949 	" Cobblestone Mine Support Wall.png",
950 	"Gray Brick.png",
951 	"Dirt.png",
952 	"Grass.png",
953 	"Green Cobblestone.png",
954 	"Red Diamond Tiles.png",
955 	"Blue Pillar.png",
956 	"Tan Brick Wall.png",
957 	"Mossy Tan Brick Wall.png",
958 	"Red Cobblestone Mine Wall.png",
959 	"Red Cobblestone Mine Support Wall.png",
960 	"water1.png",
961 	"water2.png",
962 	"water3.png",
963 	"water4.png",
964 	"water5.png",
965 	"water6.png",
966 	"water7.png",
967 	"water8.png",
968 	"Plank Ceiling.png",
969 	"Plankand Rafter Ceiling.png",
970 	"Fancy Brick Wall.png",
971 	"Fancy Gray Brick Wall.png",
972 	"sandfloor.png",
973 	"sandfloordark.png",
974 	"graytiles.png",
975 	"Roots.png",
976 	"greenbrick Crack.png",
977 	"Green Cobblestone Vine.png",
978 	"Green Cobblestone No Grass.png",
979 	"rd A.png",
980 	"rd B.png",
981 	"rd C.png",
982 	"rd D.png",
983 	"rd E.png",
984 	"rd F.png",
985 	"rd G.png",
986 	"rd H.png",
987 	"rd I.png",
988 	"Hard Stone.png",
989 	"Plankand Rafter Ceiling Horiz.png",
990 	"Red Square Tiles.png",
991 	"Trap Wall.png",
992 	"shopsign.png",
993 	"Shelf.png",
994 	"Dirt Two.png",
995 	"Purple Square Tiles.png",
996 	"Grass Two.png",
997 	"Purple Diamond Tiles.png",
998 	"Dull Green Brick.png",
999 	"Dull Green Brick Skull.png",
1000 	"Dull Green Square.png",
1001 	"Gray Dirt.png",
1002 	"Lava1.png",
1003 	"Lava2.png",
1004 	"Lava3.png",
1005 	"Lava4.png",
1006 	"Lava5.png",
1007 	"Lava6.png",
1008 	"Lava7.png",
1009 	"Lava8.png",
1010 	"Big Orange Stone.png",
1011 	"Red Pillar.png",
1012 	"Red Brick.png",
1013 	"Red Square.png",
1014 	"Red Brick Face.png",
1015 	"clouds.png",
1016 	"Magic Trap Wall1.png",
1017 	"Magic Trap Wall2.png",
1018 	"Magic Trap Wall3.png",
1019 	"Magic Trap Wall4.png",
1020 	"clouds.png",
1021 	"Leaves.png",
1022 	"Cobblestone.png",
1023 	"Cobblestone Mine Support Sides.png",
1024 	"Cobblestone Mine Support Side L.png",
1025 	"Cobblestone Mine Support Side R.png",
1026 	"Cobblestone Mine Wall Two.png",
1027 	"Cobblestone Mossy.png",
1028 	"Cobblestone Mine Support Wall Mossy.png",
1029 	"Cobblestone Mine Support Sides Mossy.png",
1030 	"Cobblestone Mine Wall Mossy.png",
1031 	"Cobblestone Mine Wall Two Mossy.png",
1032 	"Red Cobblestone Mine Wall Support Sides.png",
1033 	"Red Cobblestone Mine Wall Support L.png",
1034 	"Red Cobblestone Mine Wall Support R.png",
1035 	"Wood Two.png",
1036 	"Wood Corner NE.png",
1037 	"Wood Corner NW.png",
1038 	"Wood Corner SE.png",
1039 	"Wood Corner SW.png",
1040 	"Plankand Rafter Ceiling Cross.png",
1041 	"Gray Brick Block.png",
1042 	"Gray Brick Columns.png",
1043 	"Gray Brick Column R.png",
1044 	"Gray Brick Column L.png",
1045 	"Gray Brick Column Center.png",
1046 	"Swamp Logs.png",
1047 	"Swamp Logs Two.png",
1048 	"Swamp Log Ends.png",
1049 	"Roots Treetop.png",
1050 	"Swamp Log L.png",
1051 	"Swamp Log R.png",
1052 	"greenbricktwo.png",
1053 	"Green Cobblestone Two.png",
1054 	"Green Cobblestone Column.png",
1055 	"Green Cobblestone Column No Grass.png",
1056 	"Fancy Sandstone Wall.png",
1057 	"Orange Square Tiles.png",
1058 	"Ruin Tiles.png",
1059 	"Red Brick Face1.png",
1060 	"Red Brick Face2.png",
1061 	"Red Brick Face3.png",
1062 	"Red Brick Face4.png",
1063 	"Red Brick Face5.png",
1064 	"Red Brick Face6.png",
1065 	"Red Brick Face7.png",
1066 	"Hell Tiles.png",
1067 	"Skull Lava1.png",
1068 	"Skull Lava2.png",
1069 	"Skull Lava3.png",
1070 	"Skull Lava4.png",
1071 	"Skull Lava5.png",
1072 	"Skull Lava6.png",
1073 	"bonewall.png",
1074 	"Lavafall1.png",
1075 	"Lavafall2.png",
1076 	"Lavafall3.png",
1077 	"bonewallwithgrass.png",
1078 	"bonewallpillar.png",
1079 	"decayedstone.png",
1080 	"Dirt Path -  E.png",
1081 	"Dirt Path -  S.png",
1082 	"Dirt Path -  W.png",
1083 	"Dirt Path -  N.png",
1084 	"Dirt Path -  NE.png",
1085 	"Dirt Path -  SE.png",
1086 	"Dirt Path -  SW.png",
1087 	"Dirt Path -  NW.png",
1088 	"Dirt Path -  NE O.png",
1089 	"Dirt Path -  SE O.png",
1090 	"Dirt Path -  SW O.png",
1091 	"Dirt Path -  NW O.png",
1092 	"Cave Floor.png",
1093 	"Cave Floor Rough.png",
1094 	"Cave Wall.png",
1095 	"Cave Wall Decor.png",
1096 	"Cave Wall Crystal.png",
1097 	"Cave Wall Reinforced.png",
1098 	"Cave Wall Reinforced Left.png",
1099 	"Cave Wall Reinforced Right.png",
1100 	"Cave Wall Reinforced Center.png",
1101 	"Cave Wall Reinforced High.png",
1102 	"Cave Wall Alcove.png",
1103 	"Cave Wall Columns.png",
1104 	"Cave Wall Column Center.png",
1105 	"Cave Wall Column Left.png",
1106 	"Cave Wall Column Right.png",
1107 	"Caves To Crystal Wall Left.png",
1108 	"Caves To Crystal Wall Right.png",
1109 	"Caves To Crystal Floor -  W.png",
1110 	"Caves To Crystal Floor -  E.png",
1111 	"Caves To Crystal Floor -  S.png",
1112 	"Caves To Crystal Floor -  N.png",
1113 	"Caves To Crystal Floor -  SW.png",
1114 	"Caves To Crystal Floor -  NW.png",
1115 	"Caves To Crystal Floor -  SE.png",
1116 	"Caves To Crystal Floor -  NE.png",
1117 	"Caves To Crystal Floor -  SW O.png",
1118 	"Caves To Crystal Floor -  NW O.png",
1119 	"Caves To Crystal Floor -  SE O.png",
1120 	"Caves To Crystal Floor -  NE O.png",
1121 	"Crystal Floor.png",
1122 	"Crystal Floor Rough.png",
1123 	"Crystal Wall.png",
1124 	"Crystal Wall Decor1.png",
1125 	"Crystal Wall Decor2.png",
1126 	"Crystal Wall Decor3.png",
1127 	"Crystal Wall Decor4.png",
1128 	"Crystal Wall Reinforced.png",
1129 	"Crystal Wall Reinforced Left.png",
1130 	"Crystal Wall Reinforced Right.png",
1131 	"Crystal Wall Reinforced Center.png",
1132 	"Crystal Wall Reinforced High.png",
1133 	"Crystal Wall Columns.png",
1134 	"Crystal Wall Column Center.png",
1135 	"Crystal Wall Column Left.png",
1136 	"Crystal Wall Column Right.png",
1137 	"Bronze Columns.png",
1138 	"Bronze Columns Alcove.png",
1139 	"Submap.png",
1140 	"Cave Wall Reinforced No Beam.png",
1141 	"Cave Wall Reinforced Left Cap.png",
1142 	"Cave Wall Reinforced Right Cap.png",
1143 	"Crystal Wall Reinforced No Beam.png",
1144 	"Crystal Wall Reinforced Left Cap.png",
1145 	"Crystal Wall Reinforced Right Cap.png",
1146 	"Crystal Floor Trap 1.png",
1147 	"Crystal Floor Trap 2.png",
1148 	"Crystal Floor Trap 3.png",
1149 	"Crystal Floor Trap 4.png",
1150 	"Arcane Crystal H.png",
1151 	"Arcane Crystal J.png",
1152 	"Arcane Crystal Plating.png",
1153 	"Arcane Crystal Tile.png",
1154 	"Arcane Crystal V.png",
1155 	"Arcane Panel Blue.png",
1156 	"Arcane Panel BlueOpen.png",
1157 	"Arcane Panel Gold.png",
1158 	"Arcane Panel GoldOpen.png",
1159 	"Arcane Pipes Blue.png",
1160 	"Arcane Pipes Blue H.png",
1161 	"Arcane Pipes Blue J.png",
1162 	"Arcane Pipes Blue Plating.png",
1163 	"Arcane Pipes Blue Plating Decor.png",
1164 	"Arcane Pipes Blue V.png",
1165 	"Arcane Pipes Gold.png",
1166 	"Arcane Pipes Gold H.png",
1167 	"Arcane Pipes Gold J.png",
1168 	"Arcane Pipes Gold Plating.png",
1169 	"Arcane Pipes Gold Plating Decor.png",
1170 	"Arcane Pipes Gold V.png",
1171 	"Bronze Column Pipe.png",
1172 	"Sky.png",
1173 	"SkyCrackle.png",
1174 	"SkyCrackle_B.png",
1175 	"Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me",
1176 	"Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me",
1177 	"Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me",
1178 	"Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me",
1179 	"Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me",
1180 	"Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me",
1181 	"Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me",
1182 	"Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me",
1183 	"Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me",
1184 	"Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me",
1185 	"Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me", "Replace Me",
1186 	"Replace Me", "Replace Me", "Replace Me"
1187 };
1188 
canWearEquip(Entity * entity,int category)1189 int canWearEquip(Entity* entity, int category)
1190 {
1191 	Stat* stats;
1192 	int equipType = 0;
1193 	int type;
1194 	if ( entity != NULL )
1195 	{
1196 		stats = entity->getStats();
1197 		if ( stats != NULL )
1198 		{
1199 			type = stats->type;
1200 
1201 			switch ( type )
1202 			{
1203 				//monsters that don't wear equipment (only rings/amulets)
1204 				case DEVIL:
1205 				case SPIDER:
1206 				case TROLL:
1207 				case RAT:
1208 				case SLIME:
1209 				case SCORPION:
1210 				case MINOTAUR:
1211 				case GHOUL:
1212 				case SCARAB:
1213 				case CRYSTALGOLEM:
1214 				case COCKATRICE:
1215 					equipType = 0;
1216 					break;
1217 
1218 				//monsters with weapons only (incl. spellbooks)
1219 				case LICH:
1220 				case CREATURE_IMP:
1221 				case DEMON:
1222 					equipType = 1;
1223 					break;
1224 
1225 				//monsters with cloak/weapon/shield/boots/mask/gloves (no helm)
1226 				case GNOME:
1227 				case INCUBUS:
1228 				case SUCCUBUS:
1229 				case LICH_FIRE:
1230 				case LICH_ICE:
1231 					equipType = 2;
1232 					break;
1233 
1234 				//monsters with cloak/weapon/shield/boots/helm/armor/mask/gloves
1235 				case GOBLIN:
1236 				case HUMAN:
1237 				case VAMPIRE:
1238 				case SKELETON:
1239 				case SHOPKEEPER:
1240 				case SHADOW:
1241 				case AUTOMATON:
1242 				case GOATMAN:
1243 				case KOBOLD:
1244 				case INSECTOID:
1245 					equipType = 3;
1246 					break;
1247 
1248 				default:
1249 					equipType = 0;
1250 					break;
1251 			}
1252 		}
1253 	}
1254 
1255 	if ( category == 0 && equipType >= 3 ) //HELM
1256 	{
1257 		return 1;
1258 	}
1259 	else if ( category == 1 && equipType >= 1 ) //WEAPON
1260 	{
1261 		return 1;
1262 	}
1263 	else if ( category == 2 && equipType >= 2 ) //SHIELD
1264 	{
1265 		return 1;
1266 	}
1267 	else if ( category == 3 && equipType >= 3 ) //ARMOR
1268 	{
1269 		return 1;
1270 	}
1271 	else if ( category == 4 && equipType >= 2 ) //BOOTS
1272 	{
1273 		return 1;
1274 	}
1275 	else if ( category == 5 || category == 6 )  //RINGS/AMULETS WORN BY ALL
1276 	{
1277 		return 1;
1278 	}
1279 	else if ( (category >= 7 && category <= 9) && equipType >= 2 ) //CLOAK/MASK/GLOVES
1280 	{
1281 		return 1;
1282 	}
1283 	else
1284 	{
1285 		return 0;
1286 	}
1287 
1288 	return 0;
1289 }
1290 
setSpriteAttributes(Entity * entityNew,Entity * entityToCopy,Entity * entityStatToCopy)1291 void setSpriteAttributes(Entity* entityNew, Entity* entityToCopy, Entity* entityStatToCopy)
1292 {
1293 	Stat* tmpStats = nullptr;
1294 	if ( !entityNew )
1295 	{
1296 		return;
1297 	}
1298 
1299 	if ( entityStatToCopy != nullptr )
1300 	{
1301 		tmpStats = entityStatToCopy->getStats();
1302 	}
1303 
1304 	int spriteType = checkSpriteType(entityNew->sprite);
1305 	// monsters.
1306 	if ( spriteType == 1 )
1307 	{
1308 		//STAT ASSIGNMENT
1309 		Stat* myStats = nullptr;
1310 		if ( multiplayer != CLIENT )
1311 		{
1312 			// need to give the entity its list stuff.
1313 			// create an empty first node for traversal purposes
1314 			node_t* node2 = list_AddNodeFirst(&entityNew->children);
1315 			node2->element = nullptr;
1316 			node2->deconstructor = &emptyDeconstructor;
1317 
1318 			node2 = list_AddNodeLast(&entityNew->children);
1319 			if ( tmpStats != nullptr )
1320 			{
1321 				node2->element = tmpStats->copyStats();
1322 				node2->size = sizeof(tmpStats);
1323 			}
1324 			else
1325 			{
1326 				// if the previous sprite did not have stats initialised, or creating a new entity.
1327 				myStats = new Stat(entityNew->sprite);
1328 				node2->element = myStats;
1329 				node2->size = sizeof(myStats);
1330 			}
1331 			//					node2->deconstructor = &myStats->~Stat;
1332 		}
1333 	}
1334 	// chests.
1335 	else if ( spriteType == 2 )
1336 	{
1337 		if ( entityToCopy != nullptr )
1338 		{
1339 			// copy old entity attributes to newly created.
1340 			entityNew->yaw = entityToCopy->yaw;
1341 			entityNew->skill[9] = entityToCopy->skill[9];
1342 			entityNew->chestLocked = entityToCopy->chestLocked;
1343 		}
1344 		else
1345 		{
1346 			// set default new entity attributes.
1347 			entityNew->yaw = 1;
1348 			entityNew->skill[9] = 0;
1349 			entityNew->chestLocked = -1;
1350 		}
1351 	}
1352 	// items.
1353 	else if ( spriteType == 3 )
1354 	{
1355 		if ( entityToCopy != nullptr )
1356 		{
1357 			// copy old entity attributes to newly created.
1358 			entityNew->skill[10] = entityToCopy->skill[10];
1359 			entityNew->skill[11] = entityToCopy->skill[11];
1360 			entityNew->skill[12] = entityToCopy->skill[12];
1361 			entityNew->skill[13] = entityToCopy->skill[13];
1362 			entityNew->skill[15] = entityToCopy->skill[15];
1363 			entityNew->skill[16] = entityToCopy->skill[16];
1364 		}
1365 		else
1366 		{
1367 			// set default new entity attributes.
1368 			entityNew->skill[10] = 1;
1369 			entityNew->skill[11] = 0;
1370 			entityNew->skill[12] = 10;
1371 			entityNew->skill[13] = 1;
1372 			entityNew->skill[15] = 0;
1373 			entityNew->skill[16] = 0;
1374 		}
1375 	}
1376 	// summoning trap.
1377 	else if ( spriteType == 4 )
1378 	{
1379 		if ( entityToCopy != nullptr )
1380 		{
1381 			// copy old entity attributes to newly created.
1382 			entityNew->skill[0] = entityToCopy->skill[0];
1383 			entityNew->skill[1] = entityToCopy->skill[1];
1384 			entityNew->skill[2] = entityToCopy->skill[2];
1385 			entityNew->skill[3] = entityToCopy->skill[3];
1386 			entityNew->skill[4] = entityToCopy->skill[4];
1387 			entityNew->skill[5] = entityToCopy->skill[5];
1388 		}
1389 		else
1390 		{
1391 			// set default new entity attributes.
1392 			entityNew->skill[0] = 0;
1393 			entityNew->skill[1] = 1;
1394 			entityNew->skill[2] = 1;
1395 			entityNew->skill[3] = 1;
1396 			entityNew->skill[4] = 0;
1397 			entityNew->skill[5] = 0;
1398 		}
1399 	}
1400 	// power crystal
1401 	else if ( spriteType == 5 )
1402 	{
1403 		if ( entityToCopy != nullptr )
1404 		{
1405 			// copy old entity attributes to newly created.
1406 			entityNew->yaw = entityToCopy->yaw;
1407 			entityNew->crystalNumElectricityNodes = entityToCopy->crystalNumElectricityNodes;
1408 			entityNew->crystalTurnReverse = entityToCopy->crystalTurnReverse;
1409 			entityNew->crystalSpellToActivate = entityToCopy->crystalSpellToActivate;
1410 		}
1411 		else
1412 		{
1413 			// set default new entity attributes.
1414 			entityNew->yaw = 0;
1415 			entityNew->crystalNumElectricityNodes = 5;
1416 			entityNew->crystalTurnReverse = 0;
1417 			entityNew->crystalSpellToActivate = 0;
1418 		}
1419 	}
1420 	// lever timer
1421 	else if ( spriteType == 6 )
1422 	{
1423 		if ( entityToCopy != nullptr )
1424 		{
1425 			// copy old entity attributes to newly created.
1426 			entityNew->leverTimerTicks = entityToCopy->leverTimerTicks;
1427 		}
1428 		else
1429 		{
1430 			// set default new entity attributes.
1431 			entityNew->leverTimerTicks = 3;
1432 		}
1433 	}
1434 	// boulder trap with re-fire
1435 	else if ( spriteType == 7 )
1436 	{
1437 		if ( entityToCopy != nullptr )
1438 		{
1439 			// copy old entity attributes to newly created.
1440 			entityNew->boulderTrapRefireDelay = entityToCopy->boulderTrapRefireDelay;
1441 			entityNew->boulderTrapRefireAmount = entityToCopy->boulderTrapRefireAmount;
1442 			entityNew->boulderTrapPreDelay = entityToCopy->boulderTrapPreDelay;
1443 		}
1444 		else
1445 		{
1446 			// set default new entity attributes.
1447 			entityNew->boulderTrapRefireDelay = 3;
1448 			entityNew->boulderTrapRefireAmount = 0;
1449 			entityNew->boulderTrapPreDelay = 0;
1450 		}
1451 	}
1452 	// pedestal
1453 	else if ( spriteType == 8 )
1454 	{
1455 		if ( entityToCopy != nullptr )
1456 		{
1457 			// copy old entity attributes to newly created.
1458 			entityNew->pedestalOrbType = entityToCopy->pedestalOrbType;
1459 			entityNew->pedestalHasOrb = entityToCopy->pedestalHasOrb;
1460 			entityNew->pedestalInvertedPower = entityToCopy->pedestalInvertedPower;
1461 			entityNew->pedestalInGround = entityToCopy->pedestalInGround;
1462 			entityNew->pedestalLockOrb = entityToCopy->pedestalLockOrb;
1463 		}
1464 		else
1465 		{
1466 			// set default new entity attributes.
1467 			entityNew->pedestalOrbType = 0;
1468 			entityNew->pedestalHasOrb = 0;
1469 			entityNew->pedestalInvertedPower = 0;
1470 			entityNew->pedestalInGround = 0;
1471 			entityNew->pedestalLockOrb = 0;
1472 		}
1473 	}
1474 	// teleporter
1475 	else if ( spriteType == 9 )
1476 	{
1477 		if ( entityToCopy != nullptr )
1478 		{
1479 			// copy old entity attributes to newly created.
1480 			entityNew->teleporterX = entityToCopy->teleporterX;
1481 			entityNew->teleporterY = entityToCopy->teleporterY;
1482 			entityNew->teleporterType = entityToCopy->teleporterType;
1483 		}
1484 		else
1485 		{
1486 			// set default new entity attributes.
1487 			entityNew->teleporterX = 1;
1488 			entityNew->teleporterY = 1;
1489 			entityNew->teleporterType = 0;
1490 		}
1491 	}
1492 	// ceiling tile
1493 	else if ( spriteType == 10 )
1494 	{
1495 		if ( entityToCopy != nullptr )
1496 		{
1497 			// copy old entity attributes to newly created.
1498 			entityNew->ceilingTileModel = entityToCopy->ceilingTileModel;
1499 		}
1500 		else
1501 		{
1502 			// set default new entity attributes.
1503 			entityNew->ceilingTileModel = 0;
1504 		}
1505 	}
1506 	// spell trap
1507 	else if ( spriteType == 11 )
1508 	{
1509 		if ( entityToCopy != nullptr )
1510 		{
1511 			// copy old entity attributes to newly created.
1512 			entityNew->spellTrapType = entityToCopy->spellTrapType;
1513 			entityNew->spellTrapRefire = entityToCopy->spellTrapRefire;
1514 			entityNew->spellTrapLatchPower = entityToCopy->spellTrapLatchPower;
1515 			entityNew->spellTrapFloorTile = entityToCopy->spellTrapFloorTile;
1516 			entityNew->spellTrapRefireRate = entityToCopy->spellTrapRefireRate;
1517 		}
1518 		else
1519 		{
1520 			// set default new entity attributes.
1521 			// copy old entity attributes to newly created.
1522 			entityNew->spellTrapType = -1;
1523 			entityNew->spellTrapRefire = -1;
1524 			entityNew->spellTrapLatchPower = 0;
1525 			entityNew->spellTrapFloorTile = 0;
1526 			entityNew->spellTrapRefireRate = 1;
1527 		}
1528 	}
1529 	// furniture
1530 	else if ( spriteType == 12 )
1531 	{
1532 		if ( entityToCopy != nullptr )
1533 		{
1534 			// copy old entity attributes to newly created.
1535 			entityNew->furnitureDir = entityToCopy->furnitureDir;
1536 		}
1537 		else
1538 		{
1539 			// set default new entity attributes.
1540 			if ( entityNew->sprite == 60 ) // chair
1541 			{
1542 				entityNew->furnitureDir = -1;
1543 			}
1544 			else
1545 			{
1546 				entityNew->furnitureDir = 0;
1547 			}
1548 		}
1549 	}
1550 	// floor decoration
1551 	else if ( spriteType == 13 )
1552 	{
1553 		if ( entityToCopy != nullptr )
1554 		{
1555 			// copy old entity attributes to newly created.
1556 			entityNew->floorDecorationModel = entityToCopy->floorDecorationModel;
1557 			entityNew->floorDecorationRotation = entityToCopy->floorDecorationRotation;
1558 			entityNew->floorDecorationHeightOffset = entityToCopy->floorDecorationHeightOffset;
1559 			entityNew->floorDecorationXOffset = entityToCopy->floorDecorationXOffset;
1560 			entityNew->floorDecorationYOffset = entityToCopy->floorDecorationYOffset;
1561 			for ( int i = 8; i < 60; ++i )
1562 			{
1563 				entityNew->skill[i] = entityToCopy->skill[i];
1564 			}
1565 		}
1566 		else
1567 		{
1568 			// set default new entity attributes.
1569 			entityNew->floorDecorationModel = 0;
1570 			entityNew->floorDecorationRotation = 0;
1571 			entityNew->floorDecorationHeightOffset = 0;
1572 			entityNew->floorDecorationXOffset = 0;
1573 			entityNew->floorDecorationYOffset = 0;
1574 			for ( int i = 8; i < 60; ++i )
1575 			{
1576 				entityNew->skill[i] = 0;
1577 			}
1578 		}
1579 	}
1580 	else if ( spriteType == 14 )
1581 	{
1582 		if ( entityToCopy != nullptr )
1583 		{
1584 			// copy old entity attributes to newly created.
1585 			entityNew->soundSourceToPlay = entityToCopy->soundSourceToPlay;
1586 			entityNew->soundSourceVolume = entityToCopy->soundSourceVolume;
1587 			entityNew->soundSourceLatchOn = entityToCopy->soundSourceLatchOn;
1588 			entityNew->soundSourceDelay = entityToCopy->soundSourceDelay;
1589 			entityNew->soundSourceOrigin = entityToCopy->soundSourceOrigin;
1590 		}
1591 		else
1592 		{
1593 			// set default new entity attributes.
1594 			entityNew->soundSourceToPlay = 0;
1595 			entityNew->soundSourceVolume = 0;
1596 			entityNew->soundSourceLatchOn = 0;
1597 			entityNew->soundSourceDelay = 0;
1598 			entityNew->soundSourceOrigin = 0;
1599 		}
1600 	}
1601 	else if ( spriteType == 15 )
1602 	{
1603 		if ( entityToCopy != nullptr )
1604 		{
1605 			// copy old entity attributes to newly created.
1606 			entityNew->lightSourceAlwaysOn = entityToCopy->lightSourceAlwaysOn;
1607 			entityNew->lightSourceBrightness = entityToCopy->lightSourceBrightness;
1608 			entityNew->lightSourceInvertPower = entityToCopy->lightSourceInvertPower;
1609 			entityNew->lightSourceLatchOn = entityToCopy->lightSourceLatchOn;
1610 			entityNew->lightSourceRadius = entityToCopy->lightSourceRadius;
1611 			entityNew->lightSourceFlicker = entityToCopy->lightSourceFlicker;
1612 			entityNew->lightSourceDelay = entityToCopy->lightSourceDelay;
1613 		}
1614 		else
1615 		{
1616 			// set default new entity attributes.
1617 			entityNew->lightSourceAlwaysOn = 0;
1618 			entityNew->lightSourceBrightness = 128;
1619 			entityNew->lightSourceInvertPower = 0;
1620 			entityNew->lightSourceLatchOn = 0;
1621 			entityNew->lightSourceRadius = 5;
1622 			entityNew->lightSourceFlicker = 0;
1623 			entityNew->lightSourceDelay = 0;
1624 		}
1625 	}
1626 	else if ( spriteType == 16 )
1627 	{
1628 		if ( entityToCopy != nullptr )
1629 		{
1630 			// copy old entity attributes to newly created.
1631 			entityNew->textSourceColorRGB = entityToCopy->textSourceColorRGB;
1632 			entityNew->textSourceVariables4W = entityToCopy->textSourceVariables4W;
1633 			entityNew->textSourceDelay = entityToCopy->textSourceDelay;
1634 			entityNew->textSourceIsScript = entityToCopy->textSourceIsScript;
1635 			for ( int i = 4; i < 60; ++i )
1636 			{
1637 				entityNew->skill[i] = entityToCopy->skill[i];
1638 			}
1639 		}
1640 		else
1641 		{
1642 			// set default new entity attributes.
1643 			entityNew->textSourceColorRGB = 0xFFFFFFFF;
1644 			entityNew->textSourceVariables4W = 0;
1645 			entityNew->textSourceDelay = 0;
1646 			entityNew->textSourceIsScript = 0;
1647 			for ( int i = 4; i < 60; ++i )
1648 			{
1649 				entityNew->skill[i] = 0;
1650 			}
1651 		}
1652 	}
1653 	else if ( spriteType == 17 )
1654 	{
1655 		if ( entityToCopy != nullptr )
1656 		{
1657 			// copy old entity attributes to newly created.
1658 			entityNew->signalInputDirection = entityToCopy->signalInputDirection;
1659 			entityNew->signalActivateDelay = entityToCopy->signalActivateDelay;
1660 			entityNew->signalTimerInterval = entityToCopy->signalTimerInterval;
1661 			entityNew->signalTimerRepeatCount = entityToCopy->signalTimerRepeatCount;
1662 			entityNew->signalTimerLatchInput = entityToCopy->signalTimerLatchInput;
1663 		}
1664 		else
1665 		{
1666 			// set default new entity attributes.
1667 			entityNew->signalInputDirection = 0;
1668 			entityNew->signalActivateDelay = 0;
1669 			entityNew->signalTimerInterval = 0;
1670 			entityNew->signalTimerRepeatCount = 0;
1671 			entityNew->signalTimerLatchInput = 0;
1672 		}
1673 	}
1674 	else if ( spriteType == 18 )
1675 	{
1676 		if ( entityToCopy != nullptr )
1677 		{
1678 			// copy old entity attributes to newly created.
1679 			entityNew->portalCustomSprite = entityToCopy->portalCustomSprite;
1680 			entityNew->portalCustomSpriteAnimationFrames = entityToCopy->portalCustomSpriteAnimationFrames;
1681 			entityNew->portalCustomZOffset = entityToCopy->portalCustomZOffset;
1682 			entityNew->portalCustomLevelsToJump = entityToCopy->portalCustomLevelsToJump;
1683 			entityNew->portalNotSecret = entityToCopy->portalNotSecret;
1684 			entityNew->portalCustomRequiresPower = entityToCopy->portalCustomRequiresPower;
1685 			for ( int i = 11; i <= 18; ++i )
1686 			{
1687 				entityNew->skill[i] = entityToCopy->skill[i];
1688 			}
1689 		}
1690 		else
1691 		{
1692 			// set default new entity attributes.
1693 			entityNew->portalCustomSprite = 161;
1694 			entityNew->portalCustomSpriteAnimationFrames = 0;
1695 			entityNew->portalCustomZOffset = 8;
1696 			entityNew->portalCustomLevelsToJump = 1;
1697 			entityNew->portalNotSecret = 1;
1698 			entityNew->portalCustomRequiresPower = 0;
1699 			for ( int i = 11; i <= 18; ++i )
1700 			{
1701 				entityNew->skill[i] = 0;
1702 			}
1703 		}
1704 	}
1705 	else if ( spriteType == 19 ) // tables
1706 	{
1707 		if ( entityToCopy != nullptr )
1708 		{
1709 			// copy old entity attributes to newly created.
1710 			entityNew->furnitureDir = entityToCopy->furnitureDir;
1711 			entityNew->furnitureTableSpawnChairs = entityToCopy->furnitureTableSpawnChairs;
1712 			entityNew->furnitureTableRandomItemChance = entityToCopy->furnitureTableRandomItemChance;
1713 		}
1714 		else
1715 		{
1716 			// set default new entity attributes.
1717 			entityNew->furnitureDir = -1;
1718 			entityNew->furnitureTableSpawnChairs = -1;
1719 			entityNew->furnitureTableRandomItemChance = -1;
1720 		}
1721 	}
1722 	else if ( spriteType == 20 ) // readable book
1723 	{
1724 		if ( entityToCopy != nullptr )
1725 		{
1726 			// copy old entity attributes to newly created.
1727 			entityNew->skill[11] = entityToCopy->skill[11];
1728 			entityNew->skill[12] = entityToCopy->skill[12];
1729 			entityNew->skill[15] = entityToCopy->skill[15];
1730 			for ( int i = 40; i <= 52; ++i )
1731 			{
1732 				entityNew->skill[i] = entityToCopy->skill[i];
1733 			}
1734 		}
1735 		else
1736 		{
1737 			// set default new entity attributes.
1738 			entityNew->skill[11] = 0;
1739 			entityNew->skill[12] = 10;
1740 			entityNew->skill[15] = 0;
1741 			for ( int i = 40; i <= 52; ++i )
1742 			{
1743 				entityNew->skill[i] = 0;
1744 			}
1745 		}
1746 	}
1747 	else if ( spriteType == 21 ) // doors
1748 	{
1749 		if ( entityToCopy != nullptr )
1750 		{
1751 			// copy old entity attributes to newly created.
1752 			entityNew->doorForceLockedUnlocked = entityToCopy->doorForceLockedUnlocked;
1753 			entityNew->doorDisableLockpicks = entityToCopy->doorDisableLockpicks;
1754 			entityNew->doorDisableOpening= entityToCopy->doorDisableOpening;
1755 		}
1756 		else
1757 		{
1758 			// set default new entity attributes.
1759 			entityNew->doorForceLockedUnlocked = 0;
1760 			entityNew->doorDisableLockpicks = 0;
1761 			entityNew->doorDisableOpening = 0;
1762 		}
1763 	}
1764 	else if ( spriteType == 22 ) // gates
1765 	{
1766 		if ( entityToCopy != nullptr )
1767 		{
1768 			// copy old entity attributes to newly created.
1769 			entityNew->gateDisableOpening = entityToCopy->gateDisableOpening;
1770 		}
1771 		else
1772 		{
1773 			// set default new entity attributes.
1774 			entityNew->gateDisableOpening = 0;
1775 		}
1776 	}
1777 	else if ( spriteType == 23 ) // player spawns
1778 	{
1779 		if ( entityToCopy != nullptr )
1780 		{
1781 			// copy old entity attributes to newly created.
1782 			entityNew->playerStartDir = entityToCopy->playerStartDir;
1783 		}
1784 		else
1785 		{
1786 			// set default new entity attributes.
1787 			entityNew->playerStartDir = 0;
1788 		}
1789 	}
1790 
1791 	if ( entityToCopy != nullptr )
1792 	{
1793 		// if we are duplicating sprite, then copy the x and y coordinates.
1794 		entityNew->x = entityToCopy->x;
1795 		entityNew->y = entityToCopy->y;
1796 	}
1797 	else
1798 	{
1799 		// new entity, will follow the mouse movements when created.
1800 	}
1801 }
1802