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); }
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); }
public void RemoveFrom(EArtifactId artifactId, EArtifactPosition position) { }
public void PutAt(EArtifactId artifactId, EArtifactPosition position) { }
public bool CanPutAt(EArtifactId artifactId, EArtifactPosition position) { return(true); }
public CGArtifact(EArtifactId artId) { }
public H3Artifact(EArtifactId artId) { this.ArtifactId = artId; }