public void ResetIdleTimer(Int32 x) { if (this._context.idletimer < 0) { return; } this._context.idletimer = (Int16)(200 + Comn.random8() << 1 + (x != 0 ? 0 : 1)); }
public static void SetAutoCommand(BTL_DATA btl) { if (Status.checkCurStat(btl, 1024U)) { SetCommand(btl.cmd[0], 1U, 176U, btl_util.GetRandomBtlID((uint)(Comn.random8() & 1)), 0U); } else { if (!Status.checkCurStat(btl, 2048U)) { return; } SetCommand(btl.cmd[0], 1U, 176U, btl_util.GetRandomBtlID(0U), 0U); } }
public static Int32 SeqExecRunCamera(SEQ_WORK pSeqWork, BTL_DATA pMe) { btlseq.BattleLog("SeqExecRunCamera"); FF9StateBattleSystem ff9Battle = FF9StateSystem.Battle.FF9Battle; SEQ_WORK_SET seq_WORK_SET = ff9Battle.seq_work_set; if (btlseq.wSeqCode != 32) { if (pSeqWork.CmdPtr.aa.Info.DefaultCamera == false) { if (FF9StateSystem.Settings.cfg.camera == 1UL) { goto IL_16C; } UInt32 num = pMe.stat.cur; for (BTL_DATA next = ff9Battle.btl_list.next; next != null; next = next.next) { if ((next.btl_id & pSeqWork.CmdPtr.tar_id) != 0) { num |= next.stat.cur; } } if ((num & 335544320u) != 0u) { goto IL_16C; } if (Comn.random8() >= 128) { goto IL_16C; } } } Int16[] array = new Int16[3]; btlseq.SeqSubTargetAveragePos(pSeqWork.CmdPtr.tar_id, out array[0], out array[2]); array[1] = 0; seq_WORK_SET.CamTrgCPos = new Vector3((Single)array[0], (Single)array[1], (Single)array[2]); seq_WORK_SET.CamExe = pMe; seq_WORK_SET.CamTrg = btlseq.SeqSubGetTarget(pSeqWork.CmdPtr.tar_id); SFX.SetCameraTarget(seq_WORK_SET.CamTrgCPos, seq_WORK_SET.CamExe, seq_WORK_SET.CamTrg); ff9Battle.seq_work_set.CameraNo = btlseq.sequenceReader.ReadByte(); SFX.SetEnemyCamera(pMe); IL_16C: pSeqWork.CurPtr += 2; return(1); }
private Int32 SelectScene() { EncountData encountData = this.gMode != 1 ? ff9.w_worldGetBattleScenePtr() : this._enCountData; Int32 num = Comn.random8(); Int32 index = encountData.pattern & 3; if (num < EventEngine.d[index, 0]) { return(encountData.scene[0]); } if (num < EventEngine.d[index, 1]) { return(encountData.scene[1]); } if (num < EventEngine.d[index, 2]) { return(encountData.scene[2]); } return(encountData.scene[3]); }
private Boolean ProcessEncount(PosObj po) { Int32 SceneNo = 0; if ((Int32)this._context.usercontrol != 0 && (this._encountTimer > 960.0 || SettingsState.IsRapidEncounter)) { this._encountTimer = 0.0f; this._encountBase += (Int32)this._context.encratio; if (Comn.random8() < this._encountBase >> 3) { this._encountBase = 0; SceneNo = this.SelectScene(); if (SceneNo == this._lastScene) { SceneNo = this.SelectScene(); } this._lastScene = SceneNo; this.SetBattleScene(SceneNo); this._ff9.btlSubMapNo = -1; FF9StateSystem.Battle.isRandomEncounter = true; } } return(SceneNo != 0); }
public Int32 OperatorSelect() { Byte[] numArray = new Byte[8]; Int32 num1 = this.eBin.getv(); Int32 num2 = 0; Int32 num3 = 0; while (num3 < 8) { if ((num1 & 1) != 0) { numArray[num2++] = (Byte)num3; } ++num3; num1 >>= 1; } if (num2 == 0) { return(0); } Int32 index = num2 * Comn.random8() >> 8; return(1 << numArray[index]); }
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)); } } }
public int OperatorSelect() { byte[] numArray = new byte[8]; int num1 = this.eBin.getv(); int num2 = 0; int num3 = 0; while (num3 < 8) { if ((num1 & 1) != 0) { numArray[num2++] = (byte)num3; } ++num3; num1 >>= 1; } if (num2 == 0) { return(0); } int index = num2 * Comn.random8() >> 8; return(1 << numArray[index]); }
private bool ProcessEncount(PosObj po) { int SceneNo = 0; if ((int)this._context.usercontrol != 0 && (double)this._encountTimer > 960.0) { this._encountTimer = 0.0f; this._encountBase += (int)this._context.encratio; if (Comn.random8() < this._encountBase >> 3) { this._encountBase = 0; SceneNo = this.SelectScene(); if (SceneNo == this._lastScene) { SceneNo = this.SelectScene(); } this._lastScene = SceneNo; this.SetBattleScene(SceneNo); this._ff9.btlSubMapNo = (sbyte)-1; FF9StateSystem.Battle.isRandomEncounter = true; } } return(SceneNo != 0); }
public int GetSysvar(int code) { FF9StateBattleSystem stateBattleSystem = FF9StateSystem.Battle.FF9Battle; int num; switch (code) { case 0: num = Comn.random8(); break; case 1: num = this.fieldmap.GetCurrentCameraIndex(); break; case 2: num = (int)this._context.usercontrol; break; case 3: num = FF9Snd.ff9fldsnd_sync(); break; case 4: num = EventCollision.sSysAngle; break; case 5: Obj sender = this.getSender(this.gExec); num = -1; if (sender != null) { num = (int)sender.sid - (this.sSourceObjN - 9); break; } break; case 6: num = (int)this._ff9.party.gil; break; case 7: num = FF9StateSystem.EventState.gStepCount; break; case 8: num = ETb.gMesSignal; break; case 9: num = this.eTb.GetChoose(); break; case 10: num = this.sMapJumpX; break; case 11: num = this.sMapJumpZ; break; case 12: num = this.sSysX; break; case 13: num = this.sSysY; break; case 14: num = fldfmv.FF9FieldFMVGetFrame(); break; case 15: num = fldfmv.FF9FieldFMVSync(); break; case 16: num = (int)this._ff9.frog_no; break; case 17: num = Convert.ToInt32(TimerUI.Time); break; case 18: num = QuadMistDatabase.MiniGame_GetLastBattleResult(); break; case 19: num = FF9StateSystem.MiniGame.GetNumberOfCards(); Debug.Log((object)("num of cards = " + (object)num)); break; case 20: num = Convert.ToInt32(FF9StateSystem.Settings.time); if (num > 8388607) { num = 8388607; break; } break; case 21: num = !TimerUI.Enable ? 0 : 1; break; case 22: num = this.sSEPos; break; case 23: num = this.sSEVol; break; case 24: num = (int)this._ff9.btlMapNo; break; case 25: num = !btlseq.BtlSeqBusy() ? 0 : 1; break; case 26: num = this.gMode != 4 ? 0 : 1; break; case 27: num = (int)this._ff9.btl_result; break; case 28: num = EventEngine._btlCmdPrm >> 8 & (int)byte.MaxValue; break; case 29: num = EventEngine._btlCmdPrm & (int)byte.MaxValue; break; case 30: num = (int)stateBattleSystem.btl_phase; break; case 31: num = (int)stateBattleSystem.btl_scene.PatNum; break; default: if ((int)this.gCur.sid != 3 || this.gCur.ip != 791) { ; } num = code < 192 ? (int)btl_scrp.GetBattleData(code) : ff9.w_frameGetParameter(code); break; } return(num); }
private void idleAnimSpeed(Actor actor) { actor.aspeed = actor.idleSpeed[Comn.random8() & 3]; }
private static void FldCalcSub_220(Context v) { v.Target.cur.hp = (UInt16)(1 + Comn.random8() % 10); }
// ReSharper disable PossibleNullReferenceException public static bool CheckCommandCondition(FF9StateBattleSystem btlsys, CMD_DATA cmd) { BTL_DATA btlData = cmd.regist; FF9StateGlobal ff9StateGlobal = FF9StateSystem.Common.FF9; if (btlData != null) { if (cmd.cmd_no < 55) { int num = btl_mot.setDirection(btlData); btlData.evt.rotBattle.eulerAngles = new Vector3(btlData.evt.rotBattle.eulerAngles.x, num, btlData.evt.rotBattle.eulerAngles.z); btlData.rot.eulerAngles = new Vector3(btlData.rot.eulerAngles.x, num, btlData.rot.eulerAngles.z); } if (battle.GARNET_DEPRESS_FLAG != 0 && btlData.bi.player != 0 && (btlData.bi.slot_no == 2 && cmd.cmd_no < 48) && Comn.random8() < 64) { UIManager.Battle.SetBattleFollowMessage(27); return(false); } if (!CheckMagicCondition(cmd)) { return(false); } } byte num1 = cmd.cmd_no; switch (num1) { case 11: btlData.cmd[3].tar_id = btl_util.GetStatusBtlID(1U, 0U); break; case 12: label_12: /*int num2 = (int)*/ btl_stat.AlterStatus(btlData, 1073741824U); btlData.cmd[3].cmd_no = cmd.cmd_no; btlData.cmd[3].tar_id = cmd.cmd_no != 3 ? btl_util.GetStatusBtlID(1U, 0U) : cmd.tar_id; cmd.tar_id = btlData.btl_id; break; case 14: case 15: label_14: if (ff9item.FF9Item_GetCount(cmd.sub_no) == 0) { UIManager.Battle.SetBattleFollowMessage(24); return(false); } if (cmd.cmd_no == 51) { UIManager.Battle.SetBattleFollowMessage(9); } break; case 16: case 18: case 20: btl_calc.DecideSummonType(cmd); break; case 22: case 23: if (cmd.sub_no == 46) { btl_calc.DecideMeteor(cmd); } break; case 24: if (cmd.sub_no == 82) { cmd.tar_id = btl_util.GetRandomBtlID((uint)(Comn.random8() & 1)); break; } if (cmd.sub_no == 93 && ff9item.FF9Item_GetCount(cmd.aa.Ref.power) < btl_util.SumOfTarget(1U)) { UIManager.Battle.SetBattleFollowMessage(24); return(false); } break; case 28: case 29: if (cmd.sub_no == 126 || cmd.sub_no == 134) { uint num3 = cmd.aa.Ref.power * (uint)btlData.level; if (num3 > ff9StateGlobal.party.gil) { UIManager.Battle.SetBattleFollowMessage(20); return(false); } ff9StateGlobal.party.gil -= num3; break; } if (cmd.sub_no == 129 || cmd.sub_no == 137) { cmd.aa.Ref.attr = (byte)(1 << Comn.random8() % 8); } break; case 31: return(btl_calc.DecideMagicSword(btlData, cmd.aa.MP)); default: switch (num1) { case 49: BTL_DATA btlDataPtr1; if ((btlDataPtr1 = btl_scrp.GetBtlDataPtr(cmd.tar_id)) == null || btlDataPtr1.bi.target == 0 || Status.checkCurStat(btlDataPtr1, 256U)) { return(false); } if (btlsys.btl_scene.Info.NoNeighboring != 0 && (btlData.weapon.category & 1) != 0) { UIManager.Battle.SetBattleFollowMessage(23); return(false); } if (cmd.cmd_no == 49) { UIManager.Battle.SetBattleFollowMessage(7); } break; case 50: BTL_DATA btlDataPtr2; if ((btlDataPtr2 = btl_scrp.GetBtlDataPtr(cmd.tar_id)) == null || btlDataPtr2.bi.target == 0 || Status.checkCurStat(btlDataPtr2, 256U)) { return(false); } UIManager.Battle.SetBattleFollowMessage(8); break; case 51: goto label_14; case 52: if (btlsys.btl_scene.Info.NoNeighboring != 0 && (btlData.weapon.category & 1) != 0) { UIManager.Battle.SetBattleFollowMessage(23); return(false); } if (cmd.cmd_no == 49) { UIManager.Battle.SetBattleFollowMessage(7); } break; case 56: if (btlsys.btl_phase == 4) { for (BTL_DATA btl = btlsys.btl_list.next; btl != null; btl = btl.next) { if (btl.bi.player != 0 && !Status.checkCurStat(btl, 1107431747U) && btl.cur.hp > 0) { if (!btl_mot.checkMotion(btl, 17)) { btl_mot.setMotion(btl, 17); btl.evt.animFrame = 0; } btlsys.btl_phase = 5; btlsys.btl_seq = 3; } } if (btlsys.btl_phase == 5 && btlsys.btl_seq == 3) { UIManager.Battle.SetIdle(); ++ff9StateGlobal.party.escape_no; if (cmd.sub_no == 0) { ff9StateGlobal.btl_flag |= 4; } KillAllCommand(btlsys); } else { btlsys.cmd_status &= 65534; } return(false); } break; case 57: if (cmd.sub_no != btlsys.phantom_no) { cmd.sub_no = btlsys.phantom_no; cmd.aa = btlsys.aa_data[cmd.sub_no]; } break; case 59: if (Status.checkCurStat(btlData, 16384U)) { UIManager.Battle.SetBattleFollowMessage(6); btlData.dms_geo_id = btl_init.GetModelID(btl_util.getSerialNumber(btlData) + 19); } else { btlData.dms_geo_id = btl_init.GetModelID(btl_util.getSerialNumber(btlData)); } return(true); case 60: btl_sys.CheckBattleMenuOff(btlData); if (btlData.die_seq == 0) { btlData.die_seq = btlData.bi.player == 0 ? btlData.bi.slave != 0 || btlData.bi.death_f == 0 ? (byte)1 : (byte)3 : (!btl_mot.checkMotion(btlData, 4) ? (byte)1 : (byte)5); } return(false); case 61: btlData.cur.hp = 1; /*int num4 = (int)*/ btl_stat.RemoveStatus(btlData, 256U); btlData.bi.dmg_mot_f = 1; FF9StateSystem.Settings.SetHPFull(); return(false); case 62: btl_stat.StatusCommandCancel(btlData, 1U); btlData.stat.cur |= 1U; btlData.bi.atb = 0; btl_sys.CheckBattlePhase(btlData); /*int num5 = (int)*/ btl_stat.RemoveStatus(btlData, 2147483648U); btl_stat.SetStatusClut(btlData, true); return(false); default: switch (num1) { case 1: if (btlsys.btl_scene.Info.NoNeighboring != 0 && (btlData.weapon.category & 1) != 0 && cmd.tar_id > 15) { UIManager.Battle.SetBattleFollowMessage(23); return(false); } break; case 3: goto label_12; } break; } break; } return(true); }
public static ushort CheckReflec(CMD_DATA cmd) { ushort num1 = 0; if (cmd.cmd_no != 14 && cmd.cmd_no != 15 && (cmd.cmd_no != 51 && (cmd.aa.Category & 1) != 0) && ((int)cmd.regist.sa[0] & 1073741824) == 0) { uint num2 = cmd.tar_id >= 16 ? 1U : 0U; ushort[] numArray = new ushort[4]; short num3; short num4 = num3 = 0; for (BTL_DATA btl = FF9StateSystem.Battle.FF9Battle.btl_list.next; btl != null; btl = btl.next) { if ((btl.btl_id & cmd.tar_id) != 0) { if (!Status.checkCurStat(btl, 1U) && btl_stat.CheckStatus(btl, 536870912U)) { num1 |= btl.btl_id; ++num4; } } else if (!Status.checkCurStat(btl, 256U) && btl.bi.player == (int)num2 && btl.bi.target != 0) { numArray[num3++] = btl.btl_id; } } if (num4 != 0 && num3 != 0) { for (int index = 0; index < 4; ++index) { cmd.regist.reflec.tar_id[index] = index >= num4 ? (ushort)0 : numArray[Comn.random8() % num3]; } if (num1 == cmd.tar_id) { cmd.info.reflec = 1; cmd.tar_id = MargeReflecTargetID(cmd.regist.reflec); } else { cmd.info.reflec = 2; cmd.tar_id = (ushort)(cmd.tar_id & (uint)~num1); } } } return(num1); }
public static void SetEnemyCommand(ushort own_id, ushort tar_id, uint cmd_no, uint sub_no) { FF9StateBattleSystem stateBattleSystem = FF9StateSystem.Battle.FF9Battle; BTL_DATA btlDataPtr = btl_scrp.GetBtlDataPtr(own_id); if ((stateBattleSystem.cmd_status & 1) != 0 || Status.checkCurStat(btlDataPtr, 33689859U)) { btlDataPtr.sel_mode = 0; } else { CMD_DATA cmd; if ((int)cmd_no == 47) { if (stateBattleSystem.btl_phase != 4) { btlDataPtr.sel_mode = 0; return; } cmd = btlDataPtr.cmd[0]; if (Status.checkCurStat(btlDataPtr, 1024U)) { tar_id = btl_util.GetRandomBtlID((uint)(Comn.random8() & 1)); sub_no = btl_util.getEnemyTypePtr(btlDataPtr).p_atk_no; } else if (Status.checkCurStat(btlDataPtr, 2048U)) { tar_id = btl_util.GetRandomBtlID(1U); sub_no = btl_util.getEnemyTypePtr(btlDataPtr).p_atk_no; } } else if ((int)cmd_no == 53) { cmd = btlDataPtr.cmd[1]; } else if ((int)cmd_no == 54) { cmd = btlDataPtr.cmd[1]; } else { btlDataPtr.sel_mode = 0; return; } cmd.aa = stateBattleSystem.enemy_attack[sub_no]; cmd.tar_id = tar_id; cmd.cmd_no = (byte)cmd_no; cmd.sub_no = (byte)sub_no; cmd.info.cursor = cmd.aa.Info.cursor < 6 || cmd.aa.Info.cursor >= 13 ? (byte)0 : (byte)1; if (cmd_no > 48U) { cmd.info.priority = 1; } else { /*int num = (int)*/ btl_stat.RemoveStatus(cmd.regist, 32768U); } cmd.info.cover = 0; cmd.info.dodge = 0; cmd.info.reflec = 0; btlDataPtr.bi.cmd_idle = 1; EnqueueCommand(cmd); } }
public static void SetEnemyCommandBySequence(ushort tar_id, uint cmd_no, uint sub_no) { FF9StateBattleSystem stateBattleSystem = FF9StateSystem.Battle.FF9Battle; BTL_DATA btl = btl_scrp.GetBtlDataPtr(16); BTL_DATA[] btlDataArray = stateBattleSystem.btl_data; SEQ_WORK_SET seqWorkSet = stateBattleSystem.seq_work_set; int num1 = Array.IndexOf(seqWorkSet.AnmOfsList.Distinct().ToArray(), seqWorkSet.AnmOfsList[sub_no]); for (int index = 0; index < btlDataArray.Length; ++index) { if (num1 == btlDataArray[index].typeNo) { btl = btlDataArray[index]; break; } } if (btl == null) { return; } if ((stateBattleSystem.cmd_status & 1) != 0 || Status.checkCurStat(btl, 33689859U)) { btl.sel_mode = 0; } else { CMD_DATA cmd; if ((int)cmd_no == 47) { if (stateBattleSystem.btl_phase != 4) { btl.sel_mode = 0; return; } cmd = btl.cmd[0]; if (Status.checkCurStat(btl, 1024U)) { tar_id = btl_util.GetRandomBtlID((uint)(Comn.random8() & 1)); sub_no = btl_util.getEnemyTypePtr(btl).p_atk_no; } else if (Status.checkCurStat(btl, 2048U)) { tar_id = btl_util.GetRandomBtlID(1U); sub_no = btl_util.getEnemyTypePtr(btl).p_atk_no; } } else if ((int)cmd_no == 53) { cmd = btl.cmd[1]; } else if ((int)cmd_no == 54) { cmd = btl.cmd[1]; } else { btl.sel_mode = 0; return; } cmd.aa = stateBattleSystem.enemy_attack[sub_no]; cmd.aa.Ref.prog_no = 26; cmd.tar_id = tar_id; cmd.cmd_no = (byte)cmd_no; cmd.sub_no = (byte)sub_no; cmd.info.cursor = cmd.aa.Info.cursor < 6 || cmd.aa.Info.cursor >= 13 ? (byte)0 : (byte)1; if (cmd_no > 48U) { cmd.info.priority = 1; } else { /*int num2 = (int)*/ btl_stat.RemoveStatus(cmd.regist, 32768U); } cmd.info.cover = 0; cmd.info.dodge = 0; cmd.info.reflec = 0; btl.bi.cmd_idle = 1; EnqueueCommand(cmd); } }