private static void SerializeActions(BTL_SCENE btlScene, JsonWriter writer, String[] text, ref Int32 currentText) { writer.BeginComplexArray(); foreach (AA_DATA action in btlScene.atk) { String name = text[currentText++]; Actions.Add(new KeyValuePair <String, AA_DATA>(name, action)); writer.BeginObject(); writer.WriteString("name", name); writer.WriteEnum("targets", (TargetType)action.Info.cursor); writer.WriteBoolean("defaultAlly", action.Info.def_cur == 1); writer.WriteBoolean("defaultCamera", action.Info.def_cam != 0); writer.WriteInt16("animationId1", action.Info.vfx_no); writer.WriteUInt16("animationId2", action.Vfx2); writer.WriteByte("scriptId", action.Ref.prog_no); writer.WriteByte("power", action.Ref.power); writer.WriteFlags("elements", (EffectElement)action.Ref.attr); writer.WriteByte("rate", action.Ref.rate); writer.WriteByte("category", action.Category); writer.WriteByte("addNo", action.AddNo); writer.WriteByte("mp", action.MP); writer.WriteByte("type", action.Type); writer.WriteUInt16("name", UInt16.Parse(action.Name)); writer.EndObject(); } writer.EndComplexArray(); }
private static void SerializePatterns(BTL_SCENE btlScene, JsonWriter writer) { writer.BeginComplexArray(); foreach (SB2_PATTERN pattern in btlScene.PatAddr) { writer.BeginObject(); writer.WriteByte("rate", pattern.Rate); writer.WriteByte("enemyCount", pattern.MonCount); writer.WriteByte("camera", pattern.Camera); writer.WriteByte("pad0", pattern.Pad0); writer.WriteUInt32("ap", pattern.AP); writer.BeginComplexArray("spawn"); foreach (SB2_PUT point in pattern.Put) { writer.BeginObject(); writer.WriteByte("typeNo", point.TypeNo); writer.WriteFlags("flags", (BattleSceneSpawnFlags)point.Flags); writer.WriteByte("pease", point.Pease); writer.WriteByte("pad", point.Pad); writer.WriteInt16("x", point.Xpos); writer.WriteInt16("y", point.Ypos); writer.WriteInt16("z", point.Zpos); writer.WriteInt16("rot", point.Rot); writer.EndObject(); } writer.EndComplexArray(); writer.EndObject(); } writer.EndComplexArray(); }
private static void SerializeMain(BTL_SCENE btlScene, JsonWriter writer) { writer.BeginObject(); writer.WriteByte("version", btlScene.header.Ver); writer.WriteFlags("flags", (BattleSceneFlags)btlScene.header.Flags); writer.EndObject(); }
public static void UpdateEndBattleAchievement() { Int32 battleMapIndex = FF9StateSystem.Battle.battleMapIndex; BTL_SCENE btl_scene = FF9StateSystem.Battle.FF9Battle.btl_scene; SB2_PATTERN sb2_PATTERN = btl_scene.PatAddr[(Int32)FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum]; BattleAchievement.IncreseNumber(ref BattleAchievement.achievement.enemy_no, (Int32)sb2_PATTERN.MonCount); AchievementManager.ReportAchievement(AcheivementKey.Defeat100, BattleAchievement.achievement.enemy_no); AchievementManager.ReportAchievement(AcheivementKey.Defeat1000, BattleAchievement.achievement.enemy_no); AchievementManager.ReportAchievement(AcheivementKey.Defeat10000, BattleAchievement.achievement.enemy_no); if (battleMapIndex == 932) { AchievementManager.ReportAchievement(AcheivementKey.DefeatMaliris, 1); } else if (battleMapIndex == 933) { AchievementManager.ReportAchievement(AcheivementKey.DefeatTiamat, 1); } else if (battleMapIndex == 934) { AchievementManager.ReportAchievement(AcheivementKey.DefeatKraken, 1); } else if (battleMapIndex == 935) { AchievementManager.ReportAchievement(AcheivementKey.DefeatLich, 1); } else if (battleMapIndex == 211 || battleMapIndex == 57) { AchievementManager.ReportAchievement(AcheivementKey.DefeatOzma, 1); } else if (battleMapIndex == 634 || battleMapIndex == 627 || battleMapIndex == 755 || battleMapIndex == 753) { Int32 varManually = PersistenSingleton <EventEngine> .Instance.eBin.getVarManually(50900); Int32 num = varManually >> 3 & 31; Int32 num2 = num * 100 / 16; if (num2 >= 100) { AchievementManager.ReportAchievement(AcheivementKey.AllOX, 1); } } else if (battleMapIndex == 920 || battleMapIndex == 921) { Int32 varManually2 = PersistenSingleton <EventEngine> .Instance.eBin.getVarManually(405732); if (varManually2 == 1) { AchievementManager.ReportAchievement(AcheivementKey.YanBlessing, 1); } } else if (battleMapIndex == 339 && BattleAchievement.IsChallengingPlayerIsGarnet()) { AchievementManager.ReportAchievement(AcheivementKey.DefeatBehemoth, 1); } }
public static void SetupBattleEnemy() { SB2_PATTERN[] patAddr = FF9StateSystem.Battle.FF9Battle.btl_scene.PatAddr; SB2_HEAD header = FF9StateSystem.Battle.FF9Battle.btl_scene.header; BTL_SCENE btl_scene = FF9StateSystem.Battle.FF9Battle.btl_scene; if (FF9StateSystem.Battle.isDebug) { btl_scene.Info.StartType = FF9StateSystem.Battle.debugStartType; } else { btl_scene.Info.StartType = btl_sys.StartType(btl_scene.Info); } SB2_MON_PARM[] monAddr = FF9StateSystem.Battle.FF9Battle.btl_scene.MonAddr; AA_DATA[] atk = FF9StateSystem.Battle.FF9Battle.btl_scene.atk; Int16 num = (Int16)(header.TypCount + header.AtkCount); UInt16 num2 = 0; SB2_MON_PARM[] array = monAddr; ENEMY_TYPE[] enemy_type = FF9StateSystem.Battle.FF9Battle.enemy_type; Int16 num3; for (num3 = 0; num3 < (Int16)header.TypCount; num3 = (Int16)(num3 + 1)) { btl_init.SetMonsterParameter(array[(Int32)num3], ref enemy_type[(Int32)num3]); enemy_type[(Int32)num3].name = FF9TextTool.BattleText((Int32)num2); enemy_type[(Int32)num3].mes = (Byte)num; num = (Int16)(num + (Int16)array[(Int32)num3].MesCnt); num2 = (UInt16)(num2 + 1); } AA_DATA[] array2 = atk; AA_DATA[] enemy_attack = FF9StateSystem.Battle.FF9Battle.enemy_attack; for (num3 = 0; num3 < (Int16)header.AtkCount; num3 = (Int16)(num3 + 1)) { btl_init.SetAttackData(ref array2[(Int32)num3], ref enemy_attack[(Int32)num3]); enemy_attack[(Int32)num3].Name = FF9TextTool.BattleText((Int32)num2); num2 = (UInt16)(num2 + 1); } BTL_DATA next = FF9StateSystem.Battle.FF9Battle.btl_list.next; SB2_PATTERN sb2_PATTERN = patAddr[(Int32)FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum]; num3 = 0; while (num3 < (Int16)sb2_PATTERN.MonCount && next != null) { btl_init.PutMonster(sb2_PATTERN.Put[(Int32)num3], next, btl_scene, num3); btl_init.SetMonsterData(monAddr[(Int32)sb2_PATTERN.Put[(Int32)num3].TypeNo], next, num3); num3 = (Int16)(num3 + 1); next = next.next; } }
public static void PutMonster(SB2_PUT pPut, BTL_DATA pBtl, BTL_SCENE pScene, Int16 pNo) { Int16[] array = new Int16[3]; array[1] = 180; Int16[] array2 = array; ENEMY enemy = FF9StateSystem.Battle.FF9Battle.enemy[(Int32)pBtl.bi.slot_no]; enemy.et = FF9StateSystem.Battle.FF9Battle.enemy_type[(Int32)pPut.TypeNo]; pBtl.bi.target = (Byte)(((pPut.Flags & 1) == 0) ? 0 : 1); pBtl.bi.row = 2; pBtl.max = FF9StateSystem.Battle.FF9Battle.enemy_type[(Int32)pPut.TypeNo].max; pBtl.cur.hp = pBtl.max.hp; pBtl.cur.mp = pBtl.max.mp; enemy.info.multiple = (Byte)(((pPut.Flags & 2) == 0) ? 0 : 1); if (enemy.info.slave == 0) { Int32 index = 0; Single num = (Single)pPut.Xpos; pBtl.evt.posBattle[0] = num; pBtl.original_pos[0] = num; pBtl.base_pos[0] = num; pBtl.pos[index] = num; Int32 index2 = 1; num = (Single)(pPut.Ypos * -1); pBtl.evt.posBattle[1] = num; pBtl.original_pos[1] = num; pBtl.base_pos[1] = num; pBtl.pos[index2] = num; Int32 index3 = 2; num = (Single)pPut.Zpos; pBtl.evt.posBattle[2] = num; pBtl.original_pos[2] = num; pBtl.base_pos[2] = num; pBtl.pos[index3] = num; pBtl.rot = (pBtl.evt.rotBattle = Quaternion.Euler(new Vector3(0f, (Single)(pPut.Rot + array2[(Int32)pScene.Info.StartType] & 4095), 180f))); } else { pBtl.rot = (pBtl.evt.rotBattle = Quaternion.Euler(new Vector3(0f, 0f, 180f))); } pBtl.gameObject.transform.localPosition = pBtl.pos; pBtl.gameObject.transform.localRotation = pBtl.rot; pBtl.mot = enemy.et.mot; }
private static void SerializeScene(BTL_SCENE btlScene, String outputDirectory, String[] text) { Int32 currentText = 0; Int32 currentMessage = btlScene.header.TypCount + btlScene.header.AtkCount; String outputPath = outputDirectory + "Main.json"; using (JsonWriter writer = new JsonWriter(outputPath)) SerializeMain(btlScene, writer); outputPath = outputDirectory + "Patterns.json"; using (JsonWriter writer = new JsonWriter(outputPath)) SerializePatterns(btlScene, writer); outputPath = outputDirectory + "Enemies.json"; using (JsonWriter writer = new JsonWriter(outputPath)) SerializeEnemies(btlScene, writer, text, ref currentText, ref currentMessage); outputPath = outputDirectory + "Actions.json"; using (JsonWriter writer = new JsonWriter(outputPath)) SerializeActions(btlScene, writer, text, ref currentText); }
private static void ExportSceneSafe(String battleSceneName) { try { String relativePath = "BattleMap/BattleScene/EVT_BATTLE_" + battleSceneName + '/'; String outputDirectory = Path.Combine(Configuration.Export.Path, relativePath); String outputPath = outputDirectory + "Main.json"; if (File.Exists(outputPath)) { //Log.Warning($"[BattleSceneExporter] Export was skipped bacause a file already exists: [{outputPath}]."); //return; } Log.Message("[BattleSceneExporter] Exporting [{0}]...", battleSceneName); Int32 battleZoneId = FF9BattleDB.SceneData["BSC_" + battleSceneName]; String textEmbadedPath = EmbadedTextResources.GetCurrentPath("/Battle/" + battleZoneId + ".mes"); String[] text = EmbadedSentenseLoader.LoadSentense(textEmbadedPath); BTL_SCENE btlScene = new BTL_SCENE(); btlScene.ReadBattleScene(battleSceneName); String directoryPath = Path.GetDirectoryName(outputPath); if (directoryPath != null) { Directory.CreateDirectory(directoryPath); } SerializeScene(btlScene, outputDirectory, text); CompileScene(outputDirectory); Log.Message("[BattleSceneExporter] Exporting completed successfully."); } catch (Exception ex) { Log.Error(ex, "[BattleSceneExporter] Failed to export map [{0}].", battleSceneName); } }
public static void OrganizeEnemyData(FF9StateBattleSystem btlsys) { for (Int32 i = 0; i < BTL_SCENE.GetMonCount(); i++) { ENEMY_TYPE et = btlsys.enemy[i].et; BTL_DATA btl_DATA = btlsys.btl_data[4 + i]; btl_DATA.level = et.level; btl_DATA.max.at = (Int16)((60 - btl_DATA.elem.dex) * 40 << 2); btl_para.InitATB(btl_DATA); btl_DATA.cur.at = (Int16)(Comn.random16() % (Int32)btl_DATA.max.at); btl_DATA.weapon = (ItemAttack)null; btl_stat.InitCountDownStatus(btl_DATA); btl_mot.HideMesh(btl_DATA, btl_DATA.mesh_current, false); if (btl_DATA.bi.slave != 0) { btl_DATA.cur.at = 0; btl_DATA.cur.at_coef = 0; btl_DATA.gameObject.transform.localRotation = btl_DATA.rot; btl_DATA.gameObject.transform.localPosition = btl_DATA.evt.posBattle; btl_DATA.currentAnimationName = btl_DATA.mot[(Int32)btl_DATA.bi.def_idle]; btl_mot.setMotion(btl_DATA, btl_DATA.currentAnimationName); btl_mot.setSlavePos(btl_DATA, ref btl_DATA.base_pos); UnityEngine.Object.Destroy(btl_DATA.gameObject); UnityEngine.Object.Destroy(btl_DATA.getShadow()); btl_DATA.gameObject = btl_util.GetMasterEnemyBtlPtr().Data.gameObject; } else { btl_DATA.base_pos[0] = btl_DATA.evt.posBattle[0]; btl_DATA.base_pos[1] = btl_DATA.evt.posBattle[1]; btl_DATA.base_pos[2] = btl_DATA.evt.posBattle[2]; btl_DATA.currentAnimationName = btl_DATA.mot[(Int32)btl_DATA.bi.def_idle]; btl_DATA.evt.animFrame = (Byte)(Comn.random8() % (Int32)GeoAnim.geoAnimGetNumFrames(btl_DATA)); } } }
private void BuildBattleMapDebugPanel() { GUILayout.BeginHorizontal(new GUILayoutOption[0]); if (GUILayout.Button(" < ", new GUILayoutOption[0])) { this.mapIndex--; if (this.mapIndex < 0) { this.mapIndex = (Int32)this.mapIDs.Length - 1; } FF9StateSystem.Battle.battleMapIndex = this.mapIDs[this.mapIndex]; FF9StateSystem.Battle.patternIndex = 0; SceneDirector.Replace("BattleMapDebug", SceneTransition.FadeOutToBlack_FadeIn, true); } this.battleMapString = GUILayout.TextField(this.battleMapString, new GUILayoutOption[] { GUILayout.Width(200f) }); if (GUILayout.Button(" > ", new GUILayoutOption[0])) { this.mapIndex++; if (this.mapIndex > (Int32)this.mapIDs.Length) { this.mapIndex = 0; } FF9StateSystem.Battle.battleMapIndex = this.mapIDs[this.mapIndex]; FF9StateSystem.Battle.patternIndex = 0; SceneDirector.Replace("BattleMapDebug", SceneTransition.FadeOutToBlack_FadeIn, true); } if (GUILayout.Button("Jump", new GUILayoutOption[0])) { Int32 num = 0; Int32.TryParse(this.battleMapString, out num); if (!this.mapIDs.Contains(num)) { return; } FF9StateSystem.Battle.battleMapIndex = num; FF9StateSystem.Battle.patternIndex = 0; SoundLib.StopAllSounds(); SceneDirector.Replace("BattleMapDebug", SceneTransition.FadeOutToBlack_FadeIn, true); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); if (GUILayout.Button(" < ", new GUILayoutOption[0])) { if (this.battleMain.btlScene.header.PatCount == 1) { return; } BTL_SCENE btl_scene = FF9StateSystem.Battle.FF9Battle.btl_scene; btl_scene.PatNum = (Byte)(btl_scene.PatNum - 1); if (FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum < 0 || FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum == 255) { FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum = (Byte)(this.battleMain.btlScene.header.PatCount - 1); } this.patternIndex = String.Concat(new Object[] { "Pattern ", (Int32)(FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum + 1), " / ", this.battleMain.btlScene.header.PatCount }); FF9StateSystem.Battle.patternIndex = FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum; SceneDirector.Replace("BattleMapDebug", SceneTransition.FadeOutToBlack_FadeIn, true); } GUILayout.Label(this.patternIndex, new GUILayoutOption[] { GUILayout.Width(200f) }); if (GUILayout.Button(" > ", new GUILayoutOption[0])) { if (this.battleMain.btlScene.header.PatCount == 1) { return; } BTL_SCENE btl_scene2 = FF9StateSystem.Battle.FF9Battle.btl_scene; btl_scene2.PatNum = (Byte)(btl_scene2.PatNum + 1); if (FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum >= this.battleMain.btlScene.header.PatCount) { FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum = 0; } this.patternIndex = String.Concat(new Object[] { "Pattern ", (Int32)(FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum + 1), " / ", this.battleMain.btlScene.header.PatCount }); FF9StateSystem.Battle.patternIndex = FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum; SceneDirector.Replace("BattleMapDebug", SceneTransition.FadeOutToBlack_FadeIn, true); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUI.enabled = (btlseq.seq_work_set.SeqWork[0] != null && btlseq.seq_work_set.SeqWork[0].CmdPtr == null); if (GUILayout.Button(" < ", new GUILayoutOption[0])) { this.seqNo--; if (this.seqNo < 0) { this.seqNo = this.seqList.Count - 1; } } GUILayout.Label("sequence: " + (this.seqNo + 1), new GUILayoutOption[] { GUILayout.Width(150f) }); if (GUILayout.Button(" > ", new GUILayoutOption[0])) { this.seqNo++; if (this.seqNo >= this.seqList.Count) { this.seqNo = 0; } } if (GUILayout.Button(" Play ", new GUILayoutOption[0])) { btl_cmd.SetEnemyCommandBySequence(1, 47u, (UInt32)this.seqList[this.seqNo]); } GUI.enabled = true; GUILayout.EndHorizontal(); this.OnUiCamera(); Boolean flag = GUILayout.Toggle(FF9StateSystem.Battle.isFrontRow, "Front Row", new GUILayoutOption[0]); if (flag != FF9StateSystem.Battle.isFrontRow) { FF9StateSystem.Battle.isFrontRow = flag; this.battleMain.SetFrontRow(); } Boolean flag2 = GUILayout.Toggle(FF9StateSystem.Battle.isLevitate, "Levitate", new GUILayoutOption[0]); if (flag2 != FF9StateSystem.Battle.isLevitate) { FF9StateSystem.Battle.isLevitate = flag2; if (!flag2) { for (BTL_DATA next = FF9StateSystem.Battle.FF9Battle.btl_list.next; next != null; next = next.next) { if (next.bi.player != 0) { Vector3 pos = next.pos; pos.y = 0f; next.pos = pos; } } } } GUILayout.BeginHorizontal(new GUILayoutOption[0]); if (GUILayout.Button("Normal Attack", new GUILayoutOption[0])) { FF9StateSystem.Battle.debugStartType = 2; SceneDirector.Replace("BattleMapDebug", SceneTransition.FadeOutToBlack_FadeIn, true); } if (GUILayout.Button("First Attack", new GUILayoutOption[0])) { FF9StateSystem.Battle.debugStartType = 1; SceneDirector.Replace("BattleMapDebug", SceneTransition.FadeOutToBlack_FadeIn, true); } if (GUILayout.Button("Back Attack", new GUILayoutOption[0])) { FF9StateSystem.Battle.debugStartType = 0; SceneDirector.Replace("BattleMapDebug", SceneTransition.FadeOutToBlack_FadeIn, true); } GUILayout.EndHorizontal(); }
public void InitBattleScene() { FF9StateGlobal FF9 = FF9StateSystem.Common.FF9; FF9.charArray.Clear(); this.btlScene = FF9StateSystem.Battle.FF9Battle.btl_scene = new BTL_SCENE(); Debug.Log("battleID = " + FF9StateSystem.Battle.battleMapIndex); Dictionary <String, Int32> source = FF9BattleDB.SceneData; battleSceneName = source.FirstOrDefault(p => p.Value == FF9StateSystem.Battle.battleMapIndex).Key; battleSceneName = battleSceneName.Substring(4); Debug.Log("battleSceneName = " + battleSceneName); this.btlScene.ReadBattleScene(battleSceneName); this.StartCoroutine(PersistenSingleton <FF9TextTool> .Instance.UpdateBattleText(FF9BattleDB.SceneData["BSC_" + battleSceneName])); WMProfiler.Begin("Start Load Text"); String battleModelPath = FF9BattleDB.MapModel["BSC_" + battleSceneName]; FF9StateSystem.Battle.FF9Battle.map.btlBGPtr = ModelFactory.CreateModel("BattleMap/BattleModel/battleMap_all/" + battleModelPath + "/" + battleModelPath, Vector3.zero, Vector3.zero, true); FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum = FF9StateSystem.Battle.isDebug ? FF9StateSystem.Battle.patternIndex : (Byte)this.ChoicePattern(); this.btlSeq = new btlseq(); this.btlSeq.ReadBattleSequence(battleSceneName); BeginInitialize(); battle.InitBattle(); EndInitialize(); if (!FF9StateSystem.Battle.isDebug) { String ebFileName = "EVT_BATTLE_" + battleSceneName; FF9StateBattleMap ff9StateBattleMap = FF9StateSystem.Battle.FF9Battle.map; ff9StateBattleMap.evtPtr = EventEngineUtils.loadEventData(ebFileName, "Battle/"); PersistenSingleton <EventEngine> .Instance.StartEvents(ff9StateBattleMap.evtPtr); PersistenSingleton <EventEngine> .Instance.eTb.InitMessage(); } this.CreateBattleData(FF9); if (battleSceneName == "EF_E006" || battleSceneName == "EF_E007") { BTL_DATA btlData1 = FF9StateSystem.Battle.FF9Battle.btl_data[4]; BTL_DATA btlData2 = FF9StateSystem.Battle.FF9Battle.btl_data[5]; this.GeoBattleAttach(btlData2.gameObject, btlData1.gameObject, 55); btlData2.attachOffset = 100; } FF9StateBattleSystem stateBattleSystem = FF9StateSystem.Battle.FF9Battle; GEOTEXHEADER geotexheader = new GEOTEXHEADER(); geotexheader.ReadBGTextureAnim(battleModelPath); stateBattleSystem.map.btlBGTexAnimPtr = geotexheader; BBGINFO bbginfo = new BBGINFO(); bbginfo.ReadBattleInfo(battleModelPath); FF9StateSystem.Battle.FF9Battle.map.btlBGInfoPtr = bbginfo; btlshadow.ff9battleShadowInit(13); battle.InitBattleMap(); this.seqList = new List <Int32>(); SB2_PATTERN sb2Pattern = this.btlScene.PatAddr[FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum]; Int32[] numArray = new Int32[sb2Pattern.MonCount]; for (Int32 index = 0; index < (Int32)sb2Pattern.MonCount; ++index) { numArray[index] = sb2Pattern.Put[index].TypeNo; } foreach (Int32 num in numArray.Distinct().ToArray()) { for (Int32 index1 = 0; index1 < this.btlSeq.sequenceProperty.Length; ++index1) { SequenceProperty sequenceProperty = this.btlSeq.sequenceProperty[index1]; if (sequenceProperty.Montype == num) { for (Int32 index2 = 0; index2 < sequenceProperty.PlayableSequence.Count; ++index2) { this.seqList.Add(sequenceProperty.PlayableSequence[index2]); } } } } this.btlIDList = FF9StateSystem.Battle.FF9Battle.seq_work_set.AnmOfsList.Distinct().ToArray(); this.battleState = BattleState.PlayerTurn; playerEnterCommand = false; this.playerCastingSkill = false; this.enemyEnterCommand = false; }
public static UInt32 BattleMain() { FF9StateGlobal ff9 = FF9StateSystem.Common.FF9; FF9StateBattleSystem ff9Battle = FF9StateSystem.Battle.FF9Battle; SFX.UpdateCamera(); if (ff9Battle.btl_phase != 4 && ff9Battle.s_cur != null && ff9Battle.s_cur.activeSelf) { ff9Battle.s_cur.SetActive(false); } switch (ff9Battle.btl_phase) { case 1: battle.BattleIdleLoop(ff9, ff9Battle); break; case 2: battle.BattleLoadLoop(ff9, ff9Battle); break; case 3: if (battle.BattleIdleLoop(ff9, ff9Battle)) { if (FF9StateSystem.Common.FF9.btlMapNo == 336 && !battle.isAlreadyShowTutorial) { PersistenSingleton <UIManager> .Instance.TutorialScene.DisplayMode = TutorialUI.Mode.Battle; PersistenSingleton <UIManager> .Instance.ChangeUIState(UIManager.UIState.Tutorial); battle.isAlreadyShowTutorial = true; } if (!FF9StateSystem.Battle.isTutorial) { ff9Battle.btl_phase = 4; ff9Battle.btl_cnt = ff9Battle.btl_cnt & 15; ff9Battle.player_load_fade = 0; for (BTL_DATA next = ff9Battle.btl_list.next; next != null; next = next.next) { UInt16 startSfx; if (next.bi.player == 0 && (startSfx = BTL_SCENE.BtlGetStartSFX()) != UInt16.MaxValue) { btl_util.SetBattleSfx(next, startSfx, 127); break; } } if (battle.SUMMON_RAY_FLAG == 0) { UIManager.Battle.FF9BMenu_EnableMenu(true); } if (ff9Battle.btl_scene.Info.StartType == 0) { UIManager.Battle.SetBattleFollowMessage(2); break; } if (ff9Battle.btl_scene.Info.StartType == 1) { UIManager.Battle.SetBattleFollowMessage(1); } } } break; case 4: battle.BattleMainLoop(ff9, ff9Battle); break; case 5: if (!FF9StateSystem.Battle.isDebug) { UIManager.Battle.FF9BMenu_EnableMenu(false); } battle.BattleTrailingLoop(ff9, ff9Battle); if (ff9Battle.btl_seq != 3) { ff9Battle.btl_escape_key = 0; } break; case 6: battle.BattleIdleLoop(ff9, ff9Battle); if (ff9Battle.btl_seq == 1) { SceneDirector.FF9Wipe_FadeOutEx(32); ++ff9Battle.btl_seq; break; } if (ff9Battle.btl_seq == 2 && ff9Battle.btl_fade_time++ > 32) { return(btl_sys.ManageBattleEnd(ff9Battle)); } break; case 7: case 8: if (battle.BattleIdleLoop(ff9, ff9Battle)) { ff9.btl_flag |= 64; if (ff9Battle.btl_seq == 0) { if (ff9.btl_result != 5) { SceneDirector.FF9Wipe_FadeOutEx(32); } ++ff9Battle.btl_seq; break; } if (ff9Battle.btl_seq == 1 && ff9Battle.btl_fade_time++ > 32) { return(btl_sys.ManageBattleEnd(ff9Battle)); } } break; } if (!FF9StateSystem.Battle.isDebug) { PersistenSingleton <EventEngine> .Instance.ServiceEvents(); } ++ff9Battle.btl_cnt; return(0); }
public static void SetupBattleScene() { SB2_HEAD header = FF9StateSystem.Battle.FF9Battle.btl_scene.header; BTL_SCENE btl_scene = FF9StateSystem.Battle.FF9Battle.btl_scene; UInt16 flags = header.Flags; btl_scene.Info = new BTL_SCENE_INFO(); if ((flags & 1) != 0) { btl_scene.Info.SpecialStart = 1; } if ((flags & 2) != 0) { btl_scene.Info.BackAttack = 1; } if ((flags & 4) != 0) { btl_scene.Info.NoGameOver = 1; } if ((flags & 8) != 0) { btl_scene.Info.NoExp = 1; } if ((flags & 16) == 0) { btl_scene.Info.WinPose = 1; } if ((flags & 32) == 0) { btl_scene.Info.Runaway = 1; } if ((flags & 64) != 0) { btl_scene.Info.NoNeighboring = 1; } if ((flags & 128) != 0) { btl_scene.Info.NoMagical = true; } if ((flags & 256) != 0) { btl_scene.Info.ReverseAttack = 1; } if ((flags & 512) != 0) { btl_scene.Info.FixedCamera1 = 1; } if ((flags & 1024) != 0) { btl_scene.Info.FixedCamera2 = 1; } if ((flags & 2048) != 0) { btl_scene.Info.AfterEvent = 1; } if (FF9StateSystem.Battle.IsPlayFieldBGMInCurrentBattle) { btl_scene.Info.FieldBGM = 1; } else { btl_scene.Info.FieldBGM = 0; } battle.btl_bonus.ap = (UInt16)FF9StateSystem.Battle.FF9Battle.btl_scene.PatAddr[(Int32)FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum].AP; }
public static void SetupBattlePlayer() { BTL_SCENE btl_scene = FF9StateSystem.Battle.FF9Battle.btl_scene; Int16 num2; Int16 num = num2 = 0; while (num2 < 4) { if (FF9StateSystem.Common.FF9.party.member[(Int32)num2] != null) { num = (Int16)(num + 1); } num2 = (Int16)(num2 + 1); } Int16 num3 = 632; Int16 num4 = -1560; Int16 num5 = (Int16)((num - 1) * num3 / 2); Int16 num6 = (Int16)((btl_scene.Info.StartType != 0) ? 180 : 0); num2 = 0; BTL_DATA next = FF9StateSystem.Battle.FF9Battle.btl_list.next; while (num2 < num) { if (next.bi.player == 0) { break; } next.bi.row = FF9StateSystem.Common.FF9.player[(Int32)next.bi.slot_no].info.row; if (btl_scene.Info.StartType == 0) { BTL_INFO bi = next.bi; bi.row = (Byte)(bi.row ^ 1); } BTL_DATA btl_DATA = next; Int32 index = 0; Single num7 = (Single)num5; next.evt.posBattle[0] = num7; next.base_pos[0] = num7; btl_DATA.pos[index] = num7; BTL_DATA btl_DATA2 = next; Int32 index2 = 1; num7 = (Single)((!btl_stat.CheckStatus(next, 2097152u)) ? 0 : -200); next.evt.posBattle[1] = num7; next.base_pos[1] = num7; btl_DATA2.pos[index2] = num7; BTL_DATA btl_DATA3 = next; Int32 index3 = 2; num7 = (Single)(num4 + (Int16)((next.bi.row == 0) ? -400 : 0)); next.evt.posBattle[2] = num7; next.base_pos[2] = num7; btl_DATA3.pos[index3] = num7; next.rot = (next.evt.rotBattle = Quaternion.Euler(new Vector3(0f, (Single)num6, 180f))); next.gameObject.transform.localPosition = next.pos; next.gameObject.transform.localRotation = next.rot; Int16 serial_no = (Int16)FF9StateSystem.Common.FF9.player[(Int32)next.bi.slot_no].info.serial_no; next.shadow_bone[0] = btl_init.ShadowDataPC[(Int32)serial_no][0]; next.shadow_bone[1] = btl_init.ShadowDataPC[(Int32)serial_no][1]; btl_util.SetShadow(next, (UInt16)btl_init.ShadowDataPC[(Int32)serial_no][2], (UInt32)btl_init.ShadowDataPC[(Int32)serial_no][3]); GameObject gameObject = FF9StateSystem.Battle.FF9Battle.map.shadowArray[(Int32)next.bi.slot_no]; Vector3 localPosition = gameObject.transform.localPosition; localPosition.z = (Single)btl_init.ShadowDataPC[(Int32)serial_no][4]; gameObject.transform.localPosition = localPosition; num2 = (Int16)(num2 + 1); num5 = (Int16)(num5 - num3); next = next.next; } }
public static void InitEnemyData(FF9StateBattleSystem btlsys) { BTL_DATA btl_DATA = (BTL_DATA)null; ObjList objList = new ObjList(); if (!FF9StateSystem.Battle.isDebug) { objList = PersistenSingleton <EventEngine> .Instance.GetActiveObjList().next; } Int32 monCount = (Int32)FF9StateSystem.Battle.FF9Battle.btl_scene.PatAddr[(Int32)FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum].MonCount; Int32 i = 0; Int32 j = 4; while (i < monCount) { ENEMY enemy = btlsys.enemy[i]; BTL_DATA btl_DATA2 = btlsys.btl_data[j]; enemy.info.die_fade_rate = 32; if ((btl_DATA2.dms_geo_id = BTL_SCENE.GetMonGeoID(i)) < 0) { enemy.info.slave = 1; } else { btl_init.SetBattleModel(btl_DATA2); enemy.info.slave = 0; if (!FF9StateSystem.Battle.isDebug) { objList = objList.next; } } btl_DATA2.btl_id = (UInt16)(16 << i); btl_DATA2.bi.player = 0; btl_DATA2.bi.slot_no = (Byte)i; btl_DATA2.bi.line_no = (Byte)(4 + i); btl_DATA2.bi.t_gauge = 0; btl_DATA2.bi.slave = enemy.info.slave; BTL_SCENE btl_scene = FF9StateSystem.Battle.FF9Battle.btl_scene; SB2_PATTERN sb2_PATTERN = btl_scene.PatAddr[(Int32)FF9StateSystem.Battle.FF9Battle.btl_scene.PatNum]; SB2_MON_PARM sb2_MON_PARM = btl_scene.MonAddr[(Int32)sb2_PATTERN.Put[i].TypeNo]; UInt16 geoID = sb2_MON_PARM.Geo; btl_DATA2.height = 0; btl_DATA2.radius = 0; FF9Char ff9char = new FF9Char(); btl_init.InitBattleData(btl_DATA2, ff9char); btl_DATA2.bi.def_idle = 0; btl_DATA2.base_pos = enemy.base_pos; String path = (btl_DATA2.dms_geo_id == -1) ? String.Empty : FF9BattleDB.GEO.GetValue((Int32)btl_DATA2.dms_geo_id); if (!ModelFactory.IsUseAsEnemyCharacter(path)) { btl_DATA2.weapon_geo = (GameObject)null; } btl_DATA2.sa = btl_init.enemy_dummy_sa; FF9BattleDBHeightAndRadius.TryFindHeightAndRadius(geoID, ref btl_DATA2.height, ref btl_DATA2.radius); if (btl_DATA != null) { btl_DATA.next = btl_DATA2; } btl_DATA = btl_DATA2; i++; j++; } while (j < 8) { btlsys.btl_data[j].btl_id = 0; j++; } btl_DATA.next = (BTL_DATA)null; btlsys.btl_list.next = btlsys.btl_data[4]; btlsys.btl_load_status = (Byte)(btlsys.btl_load_status | 8); btl_init.SetupBattleEnemy(); btlseq.InitSequencer(); }
private static void SerializeEnemies(BTL_SCENE btlScene, JsonWriter writer, String[] text, ref Int32 currentText, ref Int32 currentMessage) { writer.BeginComplexArray(); foreach (SB2_MON_PARM enemy in btlScene.MonAddr) { writer.BeginObject(); writer.WriteString("name", text[currentText++]); writer.WriteUInt32("invalidStatus", enemy.Status[0]); writer.WriteUInt32("permanentStatus", enemy.Status[1]); writer.WriteUInt32("currentStatus", enemy.Status[2]); writer.WriteUInt16("maxHp", enemy.MaxHP); writer.WriteUInt16("maxMp", enemy.MaxMP); writer.WriteUInt16("winGil", enemy.WinGil); writer.WriteUInt16("winExp", enemy.WinExp); writer.BeginArray("winItems"); // 4 foreach (Byte item in enemy.WinItems) { writer.WriteByteValue(item); } writer.EndArray(); writer.BeginArray("stealItems"); // 4 foreach (Byte item in enemy.StealItems) { writer.WriteByteValue(item); } writer.EndArray(); writer.WriteUInt16("radius", enemy.Radius); writer.WriteUInt16("geo", enemy.Geo); writer.BeginArray("mot"); // 6 foreach (UInt16 item in enemy.Mot) { writer.WriteUInt16Value(item); } writer.EndArray(); writer.BeginArray("mesh"); // 2 foreach (UInt16 item in enemy.Mesh) { writer.WriteUInt16Value(item); } writer.EndArray(); writer.WriteUInt16("flags", enemy.Flags); writer.WriteUInt16("ap", enemy.AP); writer.BeginObject("element"); writer.WriteByte("dex", enemy.Element.dex); writer.WriteByte("str", enemy.Element.str); writer.WriteByte("mgc", enemy.Element.mgc); writer.WriteByte("wpr", enemy.Element.wpr); writer.WriteByte("pad", enemy.Element.pad); writer.WriteByte("trans", enemy.Element.trans); writer.WriteByte("curCapa", enemy.Element.cur_capa); writer.WriteByte("maxCapa", enemy.Element.max_capa); writer.EndObject(); writer.BeginArray("attributes"); // 4 foreach (Byte item in enemy.Attr) { writer.WriteByteValue(item); } writer.EndArray(); writer.WriteByte("level", enemy.Level); writer.WriteByte("category", enemy.Category); writer.WriteByte("hitRate", enemy.HitRate); writer.WriteByte("pdp", enemy.P_DP); writer.WriteByte("pav", enemy.P_AV); writer.WriteByte("mdp", enemy.M_DP); writer.WriteByte("mav", enemy.M_AV); writer.WriteByte("blue", enemy.Blue); writer.BeginArray("bones"); // 4 foreach (Byte item in enemy.Bone) { writer.WriteByteValue(item); } writer.EndArray(); writer.WriteUInt16("dieSfx", enemy.DieSfx); writer.WriteByte("Konran", enemy.Konran); writer.WriteByte("MesCnt", enemy.MesCnt); writer.BeginArray("iconBones"); // 6 foreach (Byte item in enemy.IconBone) { writer.WriteByteValue(item); } writer.EndArray(); writer.BeginArray("iconY"); // 6 foreach (SByte item in enemy.IconY) { writer.WriteSByteValue(item); } writer.EndArray(); writer.BeginArray("iconZ"); // 6 foreach (SByte item in enemy.IconZ) { writer.WriteSByteValue(item); } writer.EndArray(); writer.WriteUInt16("startSfx", enemy.StartSfx); writer.WriteUInt16("shadowX", enemy.ShadowX); writer.WriteUInt16("shadowZ", enemy.ShadowZ); writer.WriteByte("shadowBone", enemy.ShadowBone); writer.WriteByte("card", enemy.Card); writer.WriteInt16("shadowOfsX", enemy.ShadowOfsX); writer.WriteInt16("shadowOfsZ", enemy.ShadowOfsZ); writer.WriteByte("shadowBone2", enemy.ShadowBone2); writer.WriteByte("pad0", enemy.Pad0); writer.WriteUInt16("pad1", enemy.Pad1); writer.WriteUInt16("pad2", enemy.Pad2); writer.BeginComplexArray("messages"); for (Int32 i = 0; i < enemy.MesCnt; i++) { writer.WriteStringValue(text[currentMessage++]); } writer.EndComplexArray(); writer.EndObject(); } writer.EndComplexArray(); }