示例#1
0
        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);
        }
示例#2
0
        public override CGObject ReadObject(BinaryReader reader, int objectId, MapPosition objectPosition)
        {
            EArtifactId artId    = EArtifactId.NONE; //random, set later
            int         spellId  = -1;
            CGArtifact  artifact = new CGArtifact(artId);

            ReadMessageAndGuards(reader, artifact);

            if (this.ObjectTemplate.Type == EObjectType.SPELL_SCROLL)
            {
                spellId = (int)reader.ReadUInt32();
                artId   = EArtifactId.SPELL_SCROLL;
            }
            else if (this.ObjectTemplate.Type == EObjectType.ARTIFACT)
            {
                //specific artifact
                artId = (EArtifactId)this.ObjectTemplate.SubId;
            }

            //// artifact.StoredArtifact = CArtifactInstance::createArtifact(map, artID, spellID);

            return(artifact);
        }
示例#3
0
 public void RemoveFrom(EArtifactId artifactId, EArtifactPosition position)
 {
 }
示例#4
0
 public void PutAt(EArtifactId artifactId, EArtifactPosition position)
 {
 }
示例#5
0
 public bool CanPutAt(EArtifactId artifactId, EArtifactPosition position)
 {
     return(true);
 }
示例#6
0
 public CGArtifact(EArtifactId artId)
 {
 }
示例#7
0
 public H3Artifact(EArtifactId artId)
 {
     this.ArtifactId = artId;
 }