public static bool LoadArtifactToSlot(BinaryReader reader, H3Map map, HeroInstance hero, int slotIndex)
        {
            int artmask = 0xffff;

            if (map.Header.Version == EMapFormat.ROE)
            {
                artmask = 0xff;
            }

            int aid = reader.ReadUInt16();

            bool isArt = (aid != artmask);

            if (isArt)
            {
                Console.WriteLine("loadArtifactToSlot: id={0}, slot={1}", aid, slotIndex);

                ArtifactSet artifactSet = hero.Data.Artifacts;

                EArtifactId artifactId = (EArtifactId)aid;
                H3Artifact  artifact   = new H3Artifact(artifactId);

                if (artifact.IsBig() && slotIndex > 19)
                {
                    return(false);
                }

                EArtifactPosition slot = (EArtifactPosition)slotIndex;
                if (aid == 0 && slot == EArtifactPosition.MISC5)
                {
                    //TODO: check how H3 handles it -> art 0 in slot 18 in AB map
                    slot = EArtifactPosition.SPELLBOOK;
                }

                // this is needed, because some H3M maps (last scenario of ROE map) contain invalid data like misplaced artifacts
                //// auto artifact = CArtifactInstance::createArtifact(map, aid);
                //// auto artifactPos = ArtifactPosition(slot);

                if (artifactSet.CanPutAt(artifactId, slot))
                {
                    artifactSet.PutAt(artifactId, slot);
                }


                return(true);
            }

            return(false);
        }
Exemple #2
0
 public void RemoveFrom(EArtifactId artifactId, EArtifactPosition position)
 {
 }
Exemple #3
0
 public void PutAt(EArtifactId artifactId, EArtifactPosition position)
 {
 }
Exemple #4
0
 public bool CanPutAt(EArtifactId artifactId, EArtifactPosition position)
 {
     return(true);
 }