void ImportConsoleCommand(const char * name) { CommandInfo * info = g_consoleCommands.GetByName(name); if(info) { CommandInfo infoCopy = *info; std::string newName; newName = std::string("con_") + name; infoCopy.shortName = ""; infoCopy.longName = _strdup(newName.c_str()); g_scriptCommands.Add(&infoCopy); // _MESSAGE("imported console command %s", name); } else { _WARNING("couldn't find console command (%s)", name); // pad it g_scriptCommands.Add(&kPaddingCommand); } }
void Hooks_ObScript_Init(void) { // read vanilla commands g_commandTable.Init(0x1000, 0x1480); g_commandTable.Read(g_scriptCommandsStart, g_scriptCommandsEnd); // pad to 0x1400 to give bethesda room // pretty sure obscript is dead, but eh be safe while(g_commandTable.GetID() < 0x1400) g_commandTable.Add(); // add our commands #define CMD(name) g_commandTable.Add(&kCommandInfo_##name) CMD(GetSKSEVersion); CMD(GetSKSEVersionMinor); CMD(GetSKSEVersionBeta); CMD(GetSKSERelease); CMD(ClearInvalidRegistrations); #ifdef _DEBUG CMD(SKSETestFunc); #endif #undef CMD g_commandTable.Add(); // padding command }
void processQuery(const CommandTable& c, const std::string& cmd) { std::vector<std::string> args = split_args(strip_comments(cmd)); if (args.size() == 0) return; auto it = c.find(args[0]); if (it != c.end()) { it->second(args); } else { std::cout << "Unknown command: " << args[0] << std::endl; } }
bool Cmd_DumpDocs_Execute(COMMAND_ARGS) { if (IsConsoleMode()) { Console_Print("Dumping Command Docs"); } g_scriptCommands.DumpCommandDocumentation(); if (IsConsoleMode()) { Console_Print("Done Dumping Command Docs"); } return true; }
char *cmd_generator(const char *text, int state) { static CommandTable::const_iterator it; if (state == 0) { it = cmds.begin(); } while (it != cmds.end()) { auto s = it->first; ++it; if (boost::starts_with(s, text)) { return strdup(s.c_str()); } } return NULL; }
void CommandTable::Init(void) { static CommandInfo* kCmdInfo_Unused_1; #if RUNTIME #if RUNTIME_VERSION == RUNTIME_VERSION_1_4_0_525 kCmdInfo_Unused_1 = (CommandInfo*)0x0118E4F8; #elif RUNTIME_VERSION == RUNTIME_VERSION_1_4_0_525ng kCmdInfo_Unused_1 = (CommandInfo*)0x0118E4F8; #else #error #endif #else kCmdInfo_Unused_1 = (CommandInfo*)0x00E9D7A0; #endif // read in the console commands g_consoleCommands.SetBaseID(0x0100); g_consoleCommands.Read((CommandInfo *)g_offsetConsoleCommandsStart, (CommandInfo *)g_offsetConsoleCommandsLast); // read in the script commands g_scriptCommands.SetBaseID(0x1000); g_scriptCommands.Read((CommandInfo *)g_offsetScriptCommandsStart, (CommandInfo *)g_offsetScriptCommandsLast); // blocktype "Unused_1" becomes "Function" UInt16 onUnused_1Opcode = kCmdInfo_Unused_1->opcode; *kCmdInfo_Unused_1 = kCommandInfo_Function; kCmdInfo_Unused_1->opcode = onUnused_1Opcode; // pad to opcode 0x1400 to give Bethesda lots of room g_scriptCommands.PadTo(kNVSEOpcodeStart); // Add NVSE Commands g_scriptCommands.AddCommandsV1(); g_scriptCommands.AddCommandsV3s(); g_scriptCommands.AddCommandsV4(); #if _DEBUG g_scriptCommands.AddDebugCommands(); #endif // register plugins g_pluginManager.Init(); // patch the code ApplyPatch(kPatch_ScriptCommands_Start, (UInt32)g_scriptCommands.GetStart()); ApplyPatch(kPatch_ScriptCommands_End, (UInt32)g_scriptCommands.GetEnd()); ApplyPatch(kPatch_ScriptCommands_MaxIdx, g_scriptCommands.GetMaxID()); ApplyPatchEditorOpCodeDataList(); _MESSAGE("max id = %08X", g_scriptCommands.GetMaxID()); _MESSAGE("console commands"); g_consoleCommands.Dump(); _MESSAGE("script commands"); g_scriptCommands.Dump(); _MESSAGE("patched"); }
void CommandTable::AddCommandsV1() { // record return type of vanilla commands which return forms g_scriptCommands.SetReturnType(0x1025, kRetnType_Form); // PlaceAtMe g_scriptCommands.SetReturnType(0x10CD, kRetnType_Form); // GetActionRef g_scriptCommands.SetReturnType(0x10CE, kRetnType_Form); // GetSelf g_scriptCommands.SetReturnType(0x10CF, kRetnType_Form); // GetContainer g_scriptCommands.SetReturnType(0x10E8, kRetnType_Form); // GetCombatTarget g_scriptCommands.SetReturnType(0x10E9, kRetnType_Form); // GetPackageTarget g_scriptCommands.SetReturnType(0x1113, kRetnType_Form); // GetParentRef g_scriptCommands.SetReturnType(0x116B, kRetnType_Form); // GetLinkedRef g_scriptCommands.SetReturnType(0x11BD, kRetnType_Form); // PlaceAtMeHealthPercent g_scriptCommands.SetReturnType(0x11CF, kRetnType_Form); // GetPlayerGrabbedRef g_scriptCommands.SetReturnType(0x124E, kRetnType_Form); // GetOwnerLastTarget g_scriptCommands.SetReturnType(0x1265, kRetnType_Form); // ObjectUnderTheReticule RecordReleaseVersion(); // beta 1 ADD_CMD(GetNVSEVersion); ADD_CMD(GetNVSERevision); ADD_CMD(GetNVSEBeta); ADD_CMD_RET(GetBaseObject, kRetnType_Form); ADD_CMD(GetWeight); ADD_CMD(GetHealth); ADD_CMD(GetValue); ADD_CMD(SetWeight); ADD_CMD(SetHealth); ADD_CMD(SetBaseItemValue); ADD_CMD(GetType); ADD_CMD_RET(GetRepairList, kRetnType_Form); ADD_CMD(GetEquipType); ADD_CMD_RET(GetWeaponAmmo, kRetnType_Form); ADD_CMD(GetWeaponClipRounds); ADD_CMD(GetAttackDamage); ADD_CMD(GetWeaponType); ADD_CMD(GetWeaponMinSpread); ADD_CMD(GetWeaponSpread); ADD_CMD(GetWeaponProjectile); ADD_CMD(GetWeaponSightFOV); ADD_CMD(GetWeaponMinRange); ADD_CMD(GetWeaponMaxRange); ADD_CMD(GetWeaponAmmoUse); ADD_CMD(GetWeaponActionPoints); ADD_CMD(GetWeaponCritDamage); ADD_CMD(GetWeaponCritChance); ADD_CMD(GetWeaponCritEffect); ADD_CMD(GetWeaponFireRate); ADD_CMD(GetWeaponAnimAttackMult); ADD_CMD(GetWeaponRumbleLeftMotor); ADD_CMD(GetWeaponRumbleRightMotor); ADD_CMD(GetWeaponRumbleDuration); ADD_CMD(GetWeaponRumbleWavelength); ADD_CMD(GetWeaponAnimShotsPerSec); ADD_CMD(GetWeaponAnimReloadTime); ADD_CMD(GetWeaponAnimJamTime); ADD_CMD(GetWeaponSkill); ADD_CMD(GetWeaponResistType); ADD_CMD(GetWeaponFireDelayMin); ADD_CMD(GetWeaponFireDelayMax); ADD_CMD(GetWeaponAnimMult); ADD_CMD(GetWeaponReach); ADD_CMD(GetWeaponIsAutomatic); ADD_CMD(GetWeaponHandGrip); ADD_CMD(GetWeaponReloadAnim); ADD_CMD(GetWeaponBaseVATSChance); ADD_CMD(GetWeaponAttackAnimation); ADD_CMD(GetWeaponNumProjectiles); ADD_CMD(GetWeaponAimArc); ADD_CMD(GetWeaponLimbDamageMult); ADD_CMD(GetWeaponSightUsage); ADD_CMD(GetWeaponHasScope); ImportConsoleCommand("SetGameSetting"); ImportConsoleCommand("SetINISetting"); ImportConsoleCommand("GetINISetting"); ImportConsoleCommand("RefreshINI"); ImportConsoleCommand("Save"); ImportConsoleCommand("SaveINI"); ImportConsoleCommand("QuitGame"); ImportConsoleCommand("LoadGame"); ImportConsoleCommand("CloseAllMenus"); ImportConsoleCommand("SetVel"); ADD_CMD(ListGetCount); ADD_CMD_RET(ListGetNthForm, kRetnType_Form); ADD_CMD(ListGetFormIndex); ADD_CMD(ListAddForm); ADD_CMD(ListAddReference); ADD_CMD(ListRemoveNthForm); ADD_CMD(ListRemoveForm); ADD_CMD(ListReplaceNthForm); ADD_CMD(ListReplaceForm); ADD_CMD(ListClear); ADD_CMD_RET(GetEquippedObject, kRetnType_Form); ADD_CMD(GetEquippedCurrentHealth); ADD_CMD(CompareNames); ADD_CMD(SetName); ADD_CMD(GetHotkeyItem); ADD_CMD(GetNumItems); ADD_CMD_RET(GetInventoryObject, kRetnType_Form); ADD_CMD(SetEquippedCurrentHealth); ADD_CMD(GetCurrentHealth); ADD_CMD(SetCurrentHealth); ADD_CMD(IsKeyPressed); ADD_CMD(TapKey); ADD_CMD(HoldKey); ADD_CMD(ReleaseKey); ADD_CMD(DisableKey); ADD_CMD(EnableKey); ADD_CMD(GetNumKeysPressed); ADD_CMD(GetKeyPress); ADD_CMD(GetNumMouseButtonsPressed); ADD_CMD(GetMouseButtonPress); ADD_CMD(GetControl); ADD_CMD(GetAltControl); ADD_CMD(MenuTapKey); ADD_CMD(MenuHoldKey); ADD_CMD(MenuReleaseKey); ADD_CMD(DisableControl); ADD_CMD(EnableControl); ADD_CMD(TapControl); ADD_CMD(SetControl); ADD_CMD(SetAltControl); ADD_CMD(SetIsControl); ADD_CMD(IsControl); ADD_CMD(IsKeyDisabled); ADD_CMD(IsControlDisabled); ADD_CMD(IsControlPressed); ADD_CMD(IsPersistent); ADD_CMD_RET(GetParentCell, kRetnType_Form); ADD_CMD_RET(GetParentWorldspace, kRetnType_Form); ADD_CMD_RET(GetTeleportCell, kRetnType_Form); ADD_CMD_RET(GetLinkedDoor, kRetnType_Form); ADD_CMD_RET(GetFirstRef, kRetnType_Form); ADD_CMD_RET(GetNextRef, kRetnType_Form); ADD_CMD(GetNumRefs); ADD_CMD_RET(GetFirstRefInCell, kRetnType_Form); ADD_CMD(GetNumRefsInCell); ADD_CMD(GetRefCount); ADD_CMD(SetRefCount); ADD_CMD(GetArmorAR); ADD_CMD(IsPowerArmor); ADD_CMD(SetIsPowerArmor); ADD_CMD(SetRepairList); ADD_CMD(IsQuestItem); ADD_CMD(SetQuestItem); ADD_CMD_RET(GetObjectEffect, kRetnType_Form); ADD_CMD(SetWeaponAmmo); ADD_CMD(SetWeaponClipRounds); ADD_CMD(SetAttackDamage); ADD_CMD(SetWeaponType); ADD_CMD(SetWeaponMinSpread); ADD_CMD(SetWeaponSpread); ADD_CMD(SetWeaponProjectile); ADD_CMD(SetWeaponSightFOV); ADD_CMD(SetWeaponMinRange); ADD_CMD(SetWeaponMaxRange); ADD_CMD(SetWeaponAmmoUse); ADD_CMD(SetWeaponActionPoints); ADD_CMD(SetWeaponCritDamage); ADD_CMD(SetWeaponCritChance); ADD_CMD(SetWeaponCritEffect); ADD_CMD(SetWeaponAnimAttackMult); ADD_CMD(SetWeaponAnimMult); ADD_CMD(SetWeaponReach); ADD_CMD(SetWeaponIsAutomatic); ADD_CMD(SetWeaponHandGrip); ADD_CMD(SetWeaponReloadAnim); ADD_CMD(SetWeaponBaseVATSChance); ADD_CMD(SetWeaponAttackAnimation); ADD_CMD(SetWeaponNumProjectiles); ADD_CMD(SetWeaponAimArc); ADD_CMD(SetWeaponLimbDamageMult); ADD_CMD(SetWeaponSightUsage); ADD_CMD(GetNumericGameSetting); ADD_CMD(SetNumericGameSetting); ADD_CMD(GetNumericIniSetting); ADD_CMD(SetNumericIniSetting); ADD_CMD(Label); ADD_CMD(Goto); ADD_CMD(PrintToConsole); ADD_CMD(DebugPrint); ADD_CMD(SetDebugMode); ADD_CMD(GetDebugMode); // beta 2 ADD_CMD(GetUIFloat); ADD_CMD(SetUIFloat); ADD_CMD(SetUIString); ADD_CMD_RET(GetCrosshairRef, kRetnType_Form); ADD_CMD(GetGameRestarted); ImportConsoleCommand("ToggleMenus"); ImportConsoleCommand("TFC"); // changed from ToggleFreeCamera ImportConsoleCommand("TCL"); // changed from ToggleCollision ADD_CMD(GetGameLoaded); ADD_CMD(GetWeaponItemMod); ADD_CMD(IsModLoaded); ADD_CMD(GetModIndex); ADD_CMD(GetNumLoadedMods); ADD_CMD(GetSourceModIndex); ADD_CMD(GetDebugSelection); ADD_CMD(GetArmorDT); ADD_CMD(SetArmorAR); ADD_CMD(SetArmorDT); // beta 3 ADD_CMD(IsScripted); ADD_CMD_RET(GetScript, kRetnType_Form); ADD_CMD(RemoveScript); ADD_CMD(SetScript); ADD_CMD(IsFormValid); ADD_CMD(IsReference); // beta 4 - compat with 1.1.1.280 // oh, sorry, compat with 1.1.1.285 // oh, I am bad at reading, compat with 1.2.0.285 // beta 5 ADD_CMD(GetWeaponRequiredStrength); ADD_CMD(GetWeaponRequiredSkill); ADD_CMD(SetWeaponRequiredStrength); ADD_CMD(SetWeaponRequiredSkill); ADD_CMD(SetWeaponResistType); ADD_CMD(SetWeaponSkill); ADD_CMD(GetAmmoSpeed); ADD_CMD(GetAmmoConsumedPercent); ADD_CMD(GetAmmoCasing); ADD_CMD(GetPlayerCurrentAmmoRounds); ADD_CMD(SetPlayerCurrentAmmoRounds); ADD_CMD(GetPlayerCurrentAmmo); // beta 6 - compat with 1.2.0.314 ADD_CMD_RET(GetOpenKey, kRetnType_Form); ADD_CMD(Exp); ADD_CMD(Log10); ADD_CMD(Floor); ADD_CMD(Ceil); ADD_CMD(LeftShift); ADD_CMD(RightShift); ADD_CMD(LogicalAnd); ADD_CMD(LogicalOr); ADD_CMD(LogicalXor); ADD_CMD(LogicalNot); ADD_CMD(Pow); ADD_CMD(Fmod); ADD_CMD(Rand); // beta 7 - compat with 1.2.0.352 // beta 8 - rewrite loader to work around steam bugs // beta 9 - compat with 1.3.0.452 ADD_CMD(SortUIListBox); ADD_CMD_RET(GetOwner, kRetnType_Form); // beta 10 - compat with editor 1.3.0.452 RecordReleaseVersion(); // 2 beta 1 ADD_CMD(GetLocalRefIndex); ADD_CMD_RET(BuildRef, kRetnType_Form); ADD_CMD(SetNameEx); ADD_CMD(MessageEx); ADD_CMD(MessageBoxEx); ADD_CMD_RET(TempCloneForm, kRetnType_Form); ADD_CMD(IsClonedForm); ADD_CMD_RET(GetParentCellOwner, kRetnType_Form); ADD_CMD(GetOwningFactionRequiredRank); ADD_CMD(GetParentCellOwningFactionRequiredRank); // 2 beta 2 ADD_CMD(SetUIStringEx); // 2 beta 3 // 2 beta 4 // 2 beta 5 ImportConsoleCommand("SetUFOCamSpeedMult"); ImportConsoleCommand("TDT"); ADD_CMD(SetWeaponFireRate); ADD_CMD(GetWeaponLongBursts); ADD_CMD(SetWeaponLongBursts); // 2 beta 6 - compat with 1.4.0.525 ADD_CMD(GetWeaponFlags1); ADD_CMD(GetWeaponFlags2); ADD_CMD(SetWeaponFlags1); ADD_CMD(SetWeaponFlags2); ADD_CMD(GetActorBaseFlagsLow); ADD_CMD(SetActorBaseFlagsLow); ADD_CMD(GetActorBaseFlagsHigh); ADD_CMD(SetActorBaseFlagsHigh); ADD_CMD(ClearBit); ADD_CMD(SetBit); // 2 beta 7 - quick fix for InterfaceManager ptr // 2 beta 8 - compat with editor 1.4.0.518 // 2 beta 9 - quick fix for IsControlDisabled // 2 beta 10 - compat with nogore runtime 1.4.0.525 ADD_CMD(GetEquippedWeaponModFlags); ADD_CMD(SetEquippedWeaponModFlags); ADD_CMD(GetWeaponItemModEffect); ADD_CMD(GetWeaponItemModValue1); ADD_CMD(GetWeaponItemModValue2); // 2 beta 11 - fixed TESObjectWEAP struct (mod value 2 off by one) // 2 beta 12 - fixed GetWeaponItemModEffect etc. using 0-based indexing }
static CommandTable & commands () { static CommandTable table; if (! table.empty()) return table; table ["fork"] = boost::bind (fork, _1, _2); return table; }
/* ================================================ */ void InputWatcher::CallPadEvent() { // フェードが明けていないなら操作無効 if( FadeManager::GetInstance()->GetCurrentState() != FadeManager::STATE_IDLE ){ return; } //! ボタン情報更新 //! パッド m_preButtonState = m_buttonState; m_buttonState = GetJoypadInputState( m_watchPadIndex ); // パッドアナログスティック情報更新 for(uint32_t i = 0; i < STICK_MAX; ++i){ m_stickInfo[i] = GetStickInfo(static_cast<STICK_KIND>(i)); } //! キーボード情報更新 GetHitKeyStateAll( m_keyBoardStateChar ); for( uint32_t i = 0; i < KEY_BOARD_ARRAY_MAX ; ++i ){ m_preKeyBoardState[i] = m_keyBoardState[i]; m_keyBoardState[i] = ( m_keyBoardStateChar[i] == 0 ) ? 0 : 1 ; } SetStickInfoFromKeyBoard(); if(IsButtonEvent(BUTTON_START)){ PadEventStart(); DEBUG_PRINT("BUTTON_START\n"); } // Pause中ならStart以外操作無効 if( Utility::IsGamePause() ){ return; } if(IsButtonEvent(BUTTON_UP)){ PadEventUp(); //DEBUG_PRINT("PAD_INPUT_UP\n"); } if(IsButtonEvent(BUTTON_DOWN)){ PadEventDown(); //DEBUG_PRINT("PAD_INPUT_DOWN\n"); } if(IsButtonEvent(BUTTON_LEFT)){ PadEventLeft(); //DEBUG_PRINT("PAD_INPUT_LEFT\n"); } if(IsButtonEvent(BUTTON_RIGHT)){ PadEventRight(); //DEBUG_PRINT("PAD_INPUT_RIGHT\n"); } if(IsButtonEvent(BUTTON_DECIDE)){ PadEventDecide(); //DEBUG_PRINT("PAD_INPUT_DECIDE\n"); } if(IsButtonEvent(BUTTON_CANCEL)){ PadEventCancel(); //DEBUG_PRINT("PAD_INPUT_CANCEL\n"); } if(IsButtonEvent(BUTTON_SPECIAL1)){ PadEventSpecial1(); //DEBUG_PRINT("PAD_INPUT_SP1\n"); } if(IsButtonEvent(BUTTON_SPECIAL2)){ PadEventSpecial2(); //DEBUG_PRINT("PAD_INPUT_SP2\n"); } if(IsButtonEvent(BUTTON_L1)){ PadEventL1(); //DEBUG_PRINT("BUTTON_LB\n"); } if(IsButtonEvent(BUTTON_R1)){ PadEventR1(); //DEBUG_PRINT("BUTTON_RB\n"); } if(IsButtonEvent(BUTTON_L2)){ PadEventL2(); //DEBUG_PRINT("BUTTON_L2\n"); } if(IsButtonEvent(BUTTON_R2)){ PadEventR2(); //DEBUG_PRINT("BUTTON_R2\n"); } if(IsButtonEvent(BUTTON_SELECT)){ PadEventSelect(); //DEBUG_PRINT("BUTTON_BACK\n"); } if(IsButtonEvent(BUTTON_L3)){ PadEventL3(); //DEBUG_PRINT("BUTTON_L3\n"); } if(IsButtonEvent(BUTTON_R3)){ PadEventR3(); //DEBUG_PRINT("BUTTON_R3\n"); } //! 設定されたコマンドの確認 for(uint32_t i = 0;i < m_vCommandTable.size();++i){ CommandTable* command = m_vCommandTable.at(i); if(command->CheckCommand(m_watchPadIndex)){ //! 入力成功 PadEventCommand(command->GetCommandKind()); } } }
void Hooks_ObScript_Commit(void) { // patch the exe g_commandTable.PatchEXE(&kPatchSet); }
void CommandTable::Init(void) { // read in the console commands g_consoleCommands.SetBaseID(0x0100); g_consoleCommands.Read((CommandInfo *)g_offsetConsoleCommandsStart, (CommandInfo *)g_offsetConsoleCommandsLast); // read in the script commands g_scriptCommands.SetBaseID(0x1000); g_scriptCommands.Read((CommandInfo *)g_offsetScriptCommandsStart, (CommandInfo *)g_offsetScriptCommandsLast); // pad to opcode 0x1400 to give Bethesda lots of room g_scriptCommands.PadTo(kNVSEOpcodeStart); // Add NVSE Commands g_scriptCommands.AddCommandsV1(); #if _DEBUG g_scriptCommands.AddDebugCommands(); #endif // register plugins g_pluginManager.Init(); ApplyPatch(kPatch_ScriptCommands_Start, (UInt32)g_scriptCommands.GetStart()); ApplyPatch(kPatch_ScriptCommands_End, (UInt32)g_scriptCommands.GetEnd()); ApplyPatch(kPatch_ScriptCommands_MaxIdx, g_scriptCommands.GetMaxID()); _MESSAGE("max id = %08X", g_scriptCommands.GetMaxID()); g_scriptCommands.Dump(); _MESSAGE("patched"); }