public override CGObject ReadObject(BinaryReader reader, int objectId, MapPosition objectPosition) { CGEvent eventObject = new CGEvent(); ReadMessageAndGuards(reader, eventObject); var gainedExp = reader.ReadUInt32(); var manaDiff = reader.ReadUInt32(); var moraleDiff = reader.ReadByte(); var luckDiff = reader.ReadByte(); ResourceSet resources = ReadResources(reader); for (int x = 0; x < 4; x++) { var primSkill = (EPrimarySkill)reader.ReadByte(); } int gainedAbilities = reader.ReadByte(); for (int i = 0; i < gainedAbilities; i++) { ESecondarySkill skill = (ESecondarySkill)reader.ReadByte(); ESecondarySkillLevel level = (ESecondarySkillLevel)reader.ReadByte(); eventObject.Abilities.Add(new AbilitySkill(skill, level)); } int gainedArtifacts = reader.ReadByte(); for (int i = 0; i < gainedArtifacts; i++) { if (MapHeader.Version == EMapFormat.ROE) { var artId = (EArtifactId)reader.ReadByte(); } else { var artId = (EArtifactId)reader.ReadUInt16(); } } int gainedSpells = reader.ReadByte(); for (int i = 0; i < gainedSpells; i++) { var spellId = (ESpellId)reader.ReadByte(); } int gainedCreatures = reader.ReadByte(); var creatureSet = ReadCreatureSet(reader, gainedCreatures); reader.Skip(8); var availableForPlayer = reader.ReadByte(); var computerActivate = reader.ReadByte(); var removeAfterVisit = reader.ReadByte(); var humanActivate = true; reader.Skip(4); return(eventObject); }
public override CGObject ReadObject(BinaryReader reader, int objectId, MapPosition objectPosition) { HeroInstance hero = new HeroInstance(); if (MapHeader.Version > EMapFormat.ROE) { uint identifier = reader.ReadUInt32(); //// map->questIdentifierToId[identifier] = objectId; } EPlayerColor owner = (EPlayerColor)reader.ReadByte(); hero.SubId = reader.ReadByte(); //If hero of this type has been predefined, use that as a base. //Instance data will overwrite the predefined values where appropriate. foreach (var preHero in this.Map.PredefinedHeroes) { if (preHero.SubId == hero.SubId) { //logGlobal->debug("Hero %d will be taken from the predefined heroes list.", nhi->subID); //delete nhi; hero = preHero; break; } } hero.SetOwner(owner); //// nhi->portrait = nhi->subID; foreach (DisposedHero disHero in this.Map.DisposedHeroes) { if (disHero.HeroId == hero.SubId) { hero.Data.Name = disHero.Name; hero.Data.PortaitIndex = disHero.Portrait; break; } } bool hasName = reader.ReadBoolean(); if (hasName) { hero.Data.Name = reader.ReadStringWithLength(); } if (MapHeader.Version > EMapFormat.AB) { bool hasExp = reader.ReadBoolean(); if (hasExp) { hero.Data.Experience = reader.ReadUInt32(); } else { hero.Data.Experience = 0xffffffff; } } else { hero.Data.Experience = reader.ReadUInt32(); //0 means "not set" in <=AB maps if (hero.Data.Experience == 0) { hero.Data.Experience = 0xffffffff; } } bool hasPortrait = reader.ReadBoolean(); if (hasPortrait) { hero.Data.PortaitIndex = reader.ReadByte(); } bool hasSecSkills = reader.ReadBoolean(); if (hasSecSkills) { // Replacing with current data hero.Data.SecondarySkills = new List <AbilitySkill>(); uint howMany = reader.ReadUInt32(); for (int yy = 0; yy < howMany; ++yy) { ESecondarySkill skill = (ESecondarySkill)reader.ReadByte(); ESecondarySkillLevel level = (ESecondarySkillLevel)reader.ReadByte(); AbilitySkill abilitySkill = new AbilitySkill(skill, level); hero.Data.SecondarySkills.Add(abilitySkill); } } bool hasGarison = reader.ReadBoolean(); if (hasGarison) { hero.Data.Army = ReadCreatureSet(reader, 7); hero.Data.Army.FormationType = (EArmyFormationType)reader.ReadByte(); } else { reader.ReadByte(); } LoadArtifactsOfHero(reader, this.Map, hero); hero.Patrol = new HeroPatrol(); hero.Patrol.PatrolRadius = reader.ReadByte(); if (hero.Patrol.PatrolRadius == 0xff) { hero.Patrol.IsPatrolling = false; } else { hero.Patrol.IsPatrolling = true; hero.Patrol.InitialPosition = objectPosition; } if (this.MapHeader.Version > EMapFormat.ROE) { bool hasCustomBiography = reader.ReadBoolean(); if (hasCustomBiography) { hero.Data.Biography = reader.ReadStringWithLength(); } hero.Data.Sex = reader.ReadByte(); // Remove trash if (hero.Data.Sex != 0xFF) { hero.Data.Sex &= 1; } } else { hero.Data.Sex = 0xFF; } // Spells if (this.MapHeader.Version > EMapFormat.AB) { bool hasCustomSpells = reader.ReadBoolean(); if (hasCustomSpells) { ReadSpells(reader, hero); } } else if (this.MapHeader.Version == EMapFormat.AB) { //we can read one spell byte buff = reader.ReadByte(); if (buff != 254) { hero.Data.Spells = new List <ESpellId>(); hero.Data.Spells.Add(ESpellId.PRESET); if (buff < 254) //255 means no spells { hero.Data.Spells.Add((ESpellId)buff); } } } if (this.MapHeader.Version > EMapFormat.AB) { bool hasCustomPrimSkills = reader.ReadBoolean(); if (hasCustomPrimSkills) { hero.Data.PrimarySkills = new List <int>(); for (int xx = 0; xx < GameConstants.PRIMARY_SKILLS; ++xx) { hero.Data.PrimarySkills.Add(reader.ReadByte()); } } } reader.Skip(16); return(hero); }
public AbilitySkill(ESecondarySkill skillId, ESecondarySkillLevel level) { }