private void FillFrom(bool isAttacker, BasicCharacterObject character, int seed = -1) { if (character.Culture != null) { Character.ArmorColor1 = Utility.ClothingColor1(character.Culture, isAttacker); Character.ArmorColor2 = Utility.ClothingColor2(character.Culture, isAttacker); Character.BannerCodeText = Utility.BannerFor(character.Culture, isAttacker).Serialize(); } else { Character.ArmorColor1 = 0; Character.ArmorColor2 = 0; Character.BannerCodeText = ""; } Character.CharStringId = character.StringId; Character.IsFemale = _config.FemaleRatio > 0.5; var equipment = Utility.GetNewEquipmentsForPerks(_config.HeroClass, _config.IsHero, _config.SelectedFirstPerk, _config.SelectedSecondPerk, _config.IsHero); Character.EquipmentCode = equipment.CalculateEquipmentCode(); Character.BodyProperties = null; Character.BodyProperties = FaceGen.GetRandomBodyProperties(_config.FemaleRatio > 0.5, character.GetBodyPropertiesMin(false), character.GetBodyPropertiesMax(), (int)equipment.HairCoverType, seed, character.HairTags, character.BeardTags, character.TattooTags).ToString(); Character.MountCreationKey = MountCreationKey.GetRandomMountKey(equipment[10].Item, Common.GetDJB2(character.StringId)); }
private void FillFrom(BasicCharacterObject character, int seed = -1) { if (_teamConfig != null) { Character.ArmorColor1 = _teamConfig.Color1; Character.ArmorColor2 = _teamConfig.Color2; Character.BannerCodeText = _teamConfig.BannerKey; } else { Character.ArmorColor1 = 0; Character.ArmorColor2 = 0; Character.BannerCodeText = ""; } Character.CharStringId = character.StringId; Character.IsFemale = _config.FemaleRatio > 0.5; var equipment = character.Equipment; Character.EquipmentCode = equipment.CalculateEquipmentCode(); Character.BodyProperties = null; Character.BodyProperties = FaceGen.GetRandomBodyProperties(_config.FemaleRatio > 0.5, character.GetBodyPropertiesMin(false), character.GetBodyPropertiesMax(), (int)equipment.HairCoverType, seed, character.HairTags, character.BeardTags, character.TattooTags).ToString(); Character.MountCreationKey = MountCreationKey.GetRandomMountKey(equipment[10].Item, Common.GetDJB2(character.StringId)); }
private static void EscapeOnInit(CharacterCreation characterCreation) //Different from Base { //Use these to get private fields FaceGenChar mother = (FaceGenChar)CharacterCreationContent.Instance.GetType().GetField("_mother", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(CharacterCreationContent.Instance); FaceGenChar father = (FaceGenChar)CharacterCreationContent.Instance.GetType().GetField("_father", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(CharacterCreationContent.Instance); characterCreation.CurrentStage = CharacterCreation.Stages.EscapeMenu; characterCreation.ClearFaceGenPrefab(); ClearCharacters(characterCreation); ClearMountEntity(characterCreation); Hero @object = MBObjectManager.Instance.GetObject <Hero>("tutorial_npc_brother"); List <FaceGenChar> list = new List <FaceGenChar>(); BodyProperties bodyProperties = CharacterObject.PlayerCharacter.GetBodyProperties(CharacterObject.PlayerCharacter.Equipment, -1); bodyProperties = FaceGen.GetBodyPropertiesWithAge(ref bodyProperties, 23f); BodyProperties randomBodyProperties = BodyProperties.GetRandomBodyProperties(CharacterObject.PlayerCharacter.IsFemale, mother.BodyProperties, father.BodyProperties, 1, Hero.MainHero.Mother.CharacterObject.GetDefaultFaceSeed(1), Hero.MainHero.Father.CharacterObject.HairTags, Hero.MainHero.Father.CharacterObject.BeardTags, Hero.MainHero.Father.CharacterObject.TattooTags); randomBodyProperties = new BodyProperties(new DynamicBodyProperties(randomBodyProperties.Age, 0.5f, 0.5f), randomBodyProperties.StaticProperties); @object.ModifyPlayersFamilyAppearance(randomBodyProperties.StaticProperties); @object.DynamicBodyProperties = randomBodyProperties.DynamicProperties; list.Add(new FaceGenChar(bodyProperties, new Equipment(), CharacterObject.PlayerCharacter.IsFemale, "act_childhood_schooled")); // if (CSCharCreationOption.CSWithFamily) { list.Add(new FaceGenChar(@object.BodyProperties, new Equipment(), @object.CharacterObject.IsFemale, "act_brotherhood_schooled")); characterCreation.ChangeFaceGenChars(list); characterCreation.ChangeCharsAnimation(new List <string> { "act_childhood_schooled", "act_brotherhood_schooled" }); } else { characterCreation.ChangeFaceGenChars(list); characterCreation.ChangeCharsAnimation(new List <string> { "act_childhood_schooled", }); } //CharacterCreationContent.Instance.GetType().GetMethod("ChangeStoryStageEquipments", BindingFlags.NonPublic | BindingFlags.Static).Invoke(CharacterCreationContent.Instance, new object[] { characterCreation }); **Cant invoke due to Hardcoded change brother ChangeStoryStageEquipments(characterCreation); List <FaceGenMount> list2 = new List <FaceGenMount>(); if (CharacterObject.PlayerCharacter.HasMount()) { ItemObject item = CharacterObject.PlayerCharacter.Equipment[EquipmentIndex.ArmorItemEndSlot].Item; list2.Add(new FaceGenMount(MountCreationKey.FromString(MountCreationKey.GetRandomMountKey(item, 2)), CharacterObject.PlayerCharacter.Equipment[EquipmentIndex.ArmorItemEndSlot].Item, CharacterObject.PlayerCharacter.Equipment[EquipmentIndex.HorseHarness].Item, "act_inventory_idle_start")); } if (@object.CharacterObject.HasMount()) { ItemObject item2 = @object.CharacterObject.Equipment[EquipmentIndex.ArmorItemEndSlot].Item; list2.Add(new FaceGenMount(MountCreationKey.FromString(MountCreationKey.GetRandomMountKey(item2, 2)), @object.CharacterObject.Equipment[EquipmentIndex.ArmorItemEndSlot].Item, @object.CharacterObject.Equipment[EquipmentIndex.HorseHarness].Item, "act_inventory_idle_start")); } }
public override Agent SpawnTroop(BattleSideEnum side, bool hasFormation, bool spawnWithHorse, bool isReinforcement, bool enforceSpawningOnInitialPoint, int formationTroopCount, int formationTroopIndex, bool isAlarmed, bool wieldInitialWeapons, bool forceDismounted = false, string specialActionSet = null, MatrixFrame?initFrame = null) { BasicCharacterObject troop = Troop; var team = IsUnderPlayersCommand ? Mission.Current.PlayerTeam : Mission.Current.PlayerEnemyTeam; MatrixFrame frame = initFrame ?? Mission.Current .GetFormationSpawnFrame(team.Side, FormationClass.NumberOfRegularFormations, false).ToGroundMatrixFrame(); if (SPCharacter.IsPlayer && !forceDismounted) { spawnWithHorse = true; } AgentBuildData agentBuildData = new AgentBuildData(this) .Team(team).Banner(Banner) .ClothingColor1(team.Color).ClothingColor2(team.Color2) .NoHorses(!spawnWithHorse).CivilianEquipment(Mission.Current.DoesMissionRequireCivilianEquipment); agentBuildData.IsFemale(SPCharacter.IsFemale); if (!SPCharacter.IsPlayer) { agentBuildData.IsReinforcement(isReinforcement).SpawnOnInitialPoint(enforceSpawningOnInitialPoint); } if (!hasFormation || SPCharacter.IsPlayer) { agentBuildData.InitialFrame(frame); } if (spawnWithHorse) { agentBuildData.MountKey(MountCreationKey.GetRandomMountKey( troop.Equipment[EquipmentIndex.ArmorItemEndSlot].Item, troop.GetMountKeySeed())); } if (hasFormation && !SPCharacter.IsPlayer) { Formation formation = team.GetFormation(SPCharacter.FormationIndex); agentBuildData.Formation(formation); agentBuildData.FormationTroopCount(formationTroopCount).FormationTroopIndex(formationTroopIndex); } if (SPCharacter.IsPlayer) { agentBuildData.Controller(Agent.ControllerType.Player); } if (troop.IsHero) { agentBuildData.Equipment(troop.GetFirstEquipment(agentBuildData.AgentCivilianEquipment).Clone(false)); } else { var equipmentModifierType = BattleConfig.Instance.BattleTypeConfig.EquipmentModifierType; var equipment = Equipment.GetRandomEquipmentElements(troop, equipmentModifierType == EquipmentModifierType.Random, agentBuildData.AgentCivilianEquipment, agentBuildData.AgentEquipmentSeed); if (equipmentModifierType == EquipmentModifierType.Average) { for (EquipmentIndex index = EquipmentIndex.Weapon0; index < EquipmentIndex.NumEquipmentSetSlots; ++index) { var equipmentElement = equipment.GetEquipmentFromSlot(index); if (equipmentElement.Item != null) { if (equipmentElement.Item.HasArmorComponent) { equipmentElement.SetModifier( Utility.AverageItemModifier(equipmentElement.Item.ArmorComponent .ItemModifierGroup)); } else if (equipmentElement.Item.HasHorseComponent) { equipmentElement.SetModifier( Utility.AverageItemModifier(equipmentElement.Item.HorseComponent .ItemModifierGroup)); } } } } agentBuildData.Equipment(equipment); } Agent agent = Mission.Current.SpawnAgent(agentBuildData, false, formationTroopCount); if (agent.IsAIControlled & isAlarmed) { agent.SetWatchState(AgentAIStateFlagComponent.WatchState.Alarmed); } if (wieldInitialWeapons) { agent.WieldInitialWeapons(); } if (!specialActionSet.IsStringNoneOrEmpty()) { AnimationSystemData animationSystemData = agentBuildData.AgentMonster.FillAnimationSystemData(MBGlobals.GetActionSet(specialActionSet), agent.Character.GetStepSize(), false); AgentVisualsNativeData agentVisualsNativeData = agentBuildData.AgentMonster.FillAgentVisualsNativeData(); agentBuildData.AgentMonster.FillAgentVisualsNativeData(); agent.SetActionSet(ref agentVisualsNativeData, ref animationSystemData); } return(agent); }
public override Agent SpawnTroop(BattleSideEnum side, bool hasFormation, bool spawnWithHorse, bool isReinforcement, bool enforceSpawningOnInitialPoint, int formationTroopCount, int formationTroopIndex, bool isAlarmed, bool wieldInitialWeapons, bool forceDismounted = false, string specialActionSet = null, MatrixFrame?initFrame = null) { BasicCharacterObject troop = Troop; var team = IsUnderPlayersCommand ? Mission.Current.PlayerTeam : Mission.Current.PlayerEnemyTeam; MatrixFrame frame = initFrame ?? Mission.Current .GetFormationSpawnFrame(team.Side, FormationClass.NumberOfRegularFormations, false).ToGroundMatrixFrame(); if (MPCharacter.IsPlayer && !forceDismounted) { spawnWithHorse = true; } AgentBuildData agentBuildData = new AgentBuildData(this).Team(team).Banner(Banner) .ClothingColor1(team.Color).ClothingColor2(team.Color2) .NoHorses(!spawnWithHorse).CivilianEquipment(Mission.Current.DoesMissionRequireCivilianEquipment); var equipment = Utility.GetNewEquipmentsForPerks(MPCharacter.HeroClass, MPCharacter.IsHero, MPCharacter.SelectedFirstPerk, MPCharacter.SelectedSecondPerk, MPCharacter.IsHero, Seed); agentBuildData.Equipment(equipment); agentBuildData.IsFemale(MPCharacter.IsFemale); if (!MPCharacter.IsPlayer) { agentBuildData.IsReinforcement(isReinforcement).SpawnOnInitialPoint(enforceSpawningOnInitialPoint); } if (!hasFormation || MPCharacter.IsPlayer) { agentBuildData.InitialFrame(frame); } if (spawnWithHorse) { agentBuildData.MountKey(MountCreationKey.GetRandomMountKey( troop.Equipment[EquipmentIndex.ArmorItemEndSlot].Item, troop.GetMountKeySeed())); } if (hasFormation && !MPCharacter.IsPlayer) { Formation formation = team.GetFormation(MPCharacter.FormationIndex); agentBuildData.Formation(formation); agentBuildData.FormationTroopCount(formationTroopCount).FormationTroopIndex(formationTroopIndex); } if (MPCharacter.IsPlayer) { agentBuildData.Controller(Agent.ControllerType.Player); } Agent agent = Mission.Current.SpawnAgent(agentBuildData, false, formationTroopCount); if (agent.IsAIControlled & isAlarmed) { agent.SetWatchState(AgentAIStateFlagComponent.WatchState.Alarmed); } if (wieldInitialWeapons) { agent.WieldInitialWeapons(); } if (!specialActionSet.IsStringNoneOrEmpty()) { AnimationSystemData animationSystemData = agentBuildData.AgentMonster.FillAnimationSystemData(MBGlobals.GetActionSet(specialActionSet), agent.Character.GetStepSize(), false); AgentVisualsNativeData agentVisualsNativeData = agentBuildData.AgentMonster.FillAgentVisualsNativeData(); agentBuildData.AgentMonster.FillAgentVisualsNativeData(); agent.SetActionSet(ref agentVisualsNativeData, ref animationSystemData); } return(agent); }
public void SpawnAgentVisualsForPeer( MissionPeer missionPeer, AgentBuildData buildData, int selectedEquipmentSetIndex = -1, bool isBot = false, int totalTroopCount = 0) { NetworkCommunicator myPeer = GameNetwork.MyPeer; if (myPeer != null) { myPeer.GetComponent <MissionPeer>(); } if (buildData.AgentVisualsIndex == 0) { missionPeer.ClearAllVisuals(); } missionPeer.ClearVisuals(buildData.AgentVisualsIndex); Equipment overridenSpawnEquipment = buildData.AgentOverridenSpawnEquipment; ItemObject mountItem = overridenSpawnEquipment[10].Item; MatrixFrame pointFrameForPlayer = this._spawnFrameSelectionHelper.GetSpawnPointFrameForPlayer(missionPeer.Peer, missionPeer.Team.Side, buildData.AgentVisualsIndex, totalTroopCount, mountItem != null); ActionIndexCache actionIndexCache1 = mountItem == null ? SpawningBehaviourBase.PoseActionInfantry : SpawningBehaviourBase.PoseActionCavalry; MultiplayerClassDivisions.MPHeroClass classForCharacter = MultiplayerClassDivisions.GetMPHeroClassForCharacter(buildData.AgentCharacter); IReadOnlyList <MPPerkObject> selectedPerks = missionPeer.SelectedPerks; float parameter = (float)(0.100000001490116 + (double)MBRandom.RandomFloat * 0.800000011920929); IAgentVisual mountVisuals = (IAgentVisual)null; if (mountItem != null) { Monster monster = mountItem.HorseComponent.Monster; AgentVisualsData data = new AgentVisualsData().Equipment(overridenSpawnEquipment).Scale(mountItem.ScaleFactor).Frame(MatrixFrame.Identity).ActionSet(MBGlobals.GetActionSet(monster.ActionSetCode)).Scene(Mission.Current.Scene).Monster(monster).PrepareImmediately(false).MountCreationKey(MountCreationKey.GetRandomMountKey(mountItem, MBRandom.RandomInt())); mountVisuals = Mission.Current.AgentVisualCreator.Create(data, "Agent " + buildData.AgentCharacter.StringId + " mount", true); MatrixFrame frame = pointFrameForPlayer; frame.rotation.ApplyScaleLocal(data.ScaleData); ActionIndexCache actionName = ActionIndexCache.act_none; foreach (MPPerkObject mpPerkObject in (IEnumerable <MPPerkObject>)selectedPerks) { if (!isBot && mpPerkObject.HeroMountIdleAnimOverride != null) { actionName = ActionIndexCache.Create(mpPerkObject.HeroMountIdleAnimOverride); break; } if (isBot && mpPerkObject.TroopMountIdleAnimOverride != null) { actionName = ActionIndexCache.Create(mpPerkObject.TroopMountIdleAnimOverride); break; } } if (actionName == ActionIndexCache.act_none) { if (mountItem.StringId == "mp_aserai_camel") { Debug.Print("Client is spawning a camel for without mountCustomAction from the perk.", debugFilter: 17179869184UL); actionName = isBot ? ActionIndexCache.Create("act_camel_idle_1") : ActionIndexCache.Create("act_hero_mount_idle_camel"); } else { if (!isBot && !string.IsNullOrEmpty(classForCharacter.HeroMountIdleAnim)) { actionName = ActionIndexCache.Create(classForCharacter.HeroMountIdleAnim); } if (isBot && !string.IsNullOrEmpty(classForCharacter.TroopMountIdleAnim)) { actionName = ActionIndexCache.Create(classForCharacter.TroopMountIdleAnim); } } } if (actionName != ActionIndexCache.act_none) { mountVisuals.SetAction(actionName); mountVisuals.GetVisuals().GetSkeleton().SetAnimationParameterAtChannel(0, parameter); mountVisuals.GetVisuals().GetSkeleton().TickAnimationsAndForceUpdate(0.1f, frame, true); } mountVisuals.GetVisuals().GetEntity().SetFrame(ref frame); } ActionIndexCache actionIndexCache2 = actionIndexCache1; if (mountVisuals != null) { actionIndexCache2 = mountVisuals.GetVisuals().GetSkeleton().GetActionAtChannel(0); } else { foreach (MPPerkObject mpPerkObject in (IEnumerable <MPPerkObject>)selectedPerks) { if (!isBot && mpPerkObject.HeroIdleAnimOverride != null) { actionIndexCache2 = ActionIndexCache.Create(mpPerkObject.HeroIdleAnimOverride); break; } if (isBot && mpPerkObject.TroopIdleAnimOverride != null) { actionIndexCache2 = ActionIndexCache.Create(mpPerkObject.TroopIdleAnimOverride); break; } } if (actionIndexCache2 == actionIndexCache1) { if (!isBot && !string.IsNullOrEmpty(classForCharacter.HeroIdleAnim)) { actionIndexCache2 = ActionIndexCache.Create(classForCharacter.HeroIdleAnim); } if (isBot && !string.IsNullOrEmpty(classForCharacter.TroopIdleAnim)) { actionIndexCache2 = ActionIndexCache.Create(classForCharacter.TroopIdleAnim); } } } IAgentVisual agentVisuals = Mission.Current.AgentVisualCreator.Create(new AgentVisualsData().Equipment(overridenSpawnEquipment).BodyProperties(buildData.AgentBodyProperties).Frame(pointFrameForPlayer).ActionSet(MBGlobals.PlayerMaleActionSet).Scene(Mission.Current.Scene).Monster(Game.Current.HumanMonster).PrepareImmediately(false).UseMorphAnims(true).SkeletonType(buildData.AgentIsFemale ? SkeletonType.Female : SkeletonType.Male).ClothColor1(buildData.AgentClothingColor1).ClothColor2(buildData.AgentClothingColor2).AddColorRandomness((uint)buildData.AgentVisualsIndex > 0U).ActionCode(actionIndexCache2), "Mission::SpawnAgentVisuals", true); agentVisuals.SetAction(actionIndexCache2); agentVisuals.GetVisuals().GetSkeleton().SetAnimationParameterAtChannel(0, parameter); agentVisuals.GetVisuals().GetSkeleton().TickAnimationsAndForceUpdate(0.1f, pointFrameForPlayer, true); agentVisuals.GetVisuals().SetFrame(ref pointFrameForPlayer); agentVisuals.SetCharacterObjectID(buildData.AgentCharacter.StringId); EquipmentIndex mainHandWeaponIndex; EquipmentIndex offHandWeaponIndex; bool isMainHandNotUsableWithOneHand; overridenSpawnEquipment.GetInitialWeaponIndicesToEquip(out mainHandWeaponIndex, out offHandWeaponIndex, out isMainHandNotUsableWithOneHand); if (isMainHandNotUsableWithOneHand) { offHandWeaponIndex = EquipmentIndex.None; } agentVisuals.GetVisuals().SetWieldedWeaponIndices((int)mainHandWeaponIndex, (int)offHandWeaponIndex); PeerVisualsHolder visualsHolder = new PeerVisualsHolder(missionPeer, buildData.AgentVisualsIndex, agentVisuals, mountVisuals); missionPeer.OnVisualsSpawned(visualsHolder, visualsHolder.VisualsIndex); if (buildData.AgentVisualsIndex == 0) { missionPeer.HasSpawnedAgentVisuals = true; missionPeer.EquipmentUpdatingExpired = false; } if (!missionPeer.IsMine || buildData.AgentVisualsIndex != 0) { return; } Action agentVisualSpawned = this.OnMyAgentVisualSpawned; if (agentVisualSpawned == null) { return; } agentVisualSpawned(); }