bool Cmd_GetStringIniSetting_Execute(COMMAND_ARGS) { char settingName[kMaxMessageLength] = { 0 }; *result = -1; if (ExtractArgs(EXTRACT_ARGS, &settingName)) { Setting* setting; if (GetIniSetting(settingName, &setting)) { char val[kMaxMessageLength] = { 0 }; if (const char * pVal = setting->Get()) { strcpy_s(val, kMaxMessageLength, pVal); AssignToStringVar(PASS_COMMAND_ARGS, val); if (IsConsoleMode()) Console_Print("GetStringIniSetting >> %s", val); } } else if (IsConsoleMode()) Console_Print("GetStringIniSetting >> SETTING NOT FOUND"); } return true; }
static bool Cmd_SetCellResetHours_Execute(COMMAND_ARGS) { // specifies # of hours from now until cell reset *result = 0; TESObjectCELL* cell = NULL; UInt32 numHours = -1; if (ExtractArgs(PASS_EXTRACT_ARGS, &cell, &numHours) && cell && numHours != -1) { if (cell->IsInterior() && cell != (*g_thePlayer)->parentCell) { SInt32 iHoursToRespawn = TimeGlobals::HoursToRespawnCell(); SInt32 iHoursPassed = TimeGlobals::GameHoursPassed(); SInt32 detachTime = iHoursPassed + numHours - iHoursToRespawn; if (detachTime < iHoursPassed) { *result = 1; CALL_MEMBER_FN(cell, SetDetachTime)(detachTime); if (IsConsoleMode()) Console_Print("Current hours passed :%d Detach time: %d", iHoursPassed, detachTime); } else if (IsConsoleMode()) Console_Print("Detach time %d cannot be greater than current hours passed %d", detachTime, iHoursPassed); } } return true; }
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; }
static bool Cmd_GetRuntimeEditorID_Execute(COMMAND_ARGS) { TESForm* BaseObject = NULL; if (!g_scriptIntfc->ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &BaseObject) || (thisObj == NULL && BaseObject == NULL)) { g_strVarInfc->Assign(PASS_COMMAND_ARGS, ""); return true; } UInt32 FormID = 0; if (thisObj) FormID = thisObj->refID; else if (BaseObject) FormID = BaseObject->refID; const char* EditorID = g_editorIDManager.LookupByFormID(FormID); if (EditorID == NULL && BaseObject) EditorID = BaseObject->GetEditorID(); if (EditorID == NULL) g_strVarInfc->Assign(PASS_COMMAND_ARGS, ""); else { g_strVarInfc->Assign(PASS_COMMAND_ARGS, EditorID); if (IsConsoleMode()) Console_Print("EditorID: %s", EditorID); } return true; }
/* Return a float value from the given file. * syntax: FloatFromFile filename line_number * shortname: ffromf * * Gets a float from the given line from the file [filename], starting with line 0. * -If line_number <= 0, get the first line of the file. * -If line_number >= (lines_in_file - 1), get the last line of the file. * * -Filename is relative to the path where Oblivion.exe is located. * -Integers can be read from file, but will be returned as floats (range limits on floats may apply). * -This function has been tested using the Oblivion console. More testing might be needed in scripts to make sure the * returned value is correct. * -Prints an error to the console and returns nothing if the file is not found. */ bool Cmd_FloatFromFile_Execute(COMMAND_ARGS) { *result = 0.0; char lineBuffer[BUFSIZ]; FILE* fileptr; int currLine = 0; char filename[129]; int linePos; //just return with error message if file can't be opened if (!(ExtractArgs(paramInfo, arg1, opcodeOffsetPtr, thisObj, arg3, scriptObj, eventList, &filename, &linePos)) || fopen_s(&fileptr, filename, "r")) { Console_Print ("File %s could not be opened.", filename); return true; } //fgets() will move the file pointer to next line for us, allowing for variable line lengths while (fgets (lineBuffer, BUFSIZ, fileptr) && currLine < linePos) { currLine++; } *result = (float) atof(lineBuffer); //Console_Print ("Line %d: %f", linePos, *result); fclose (fileptr); return true; }
bool Cmd_ListAddForm_Execute(COMMAND_ARGS) { *result = eListInvalid; BGSListForm* pListForm = NULL; TESForm* pForm = NULL; UInt32 n = eListEnd; #if REPORT_BAD_FORMLISTS __try { #endif ExtractArgsEx(EXTRACT_ARGS_EX, &pListForm, &pForm, &n); if (pListForm && pForm) { UInt32 index = pListForm->AddAt(pForm, n); if (index != eListInvalid) { *result = index; } if (IsConsoleMode()) { Console_Print("Index: %d", index); } } #if REPORT_BAD_FORMLISTS } __except(EXCEPTION_EXECUTE_HANDLER) { ReportBadFormlist(PASS_COMMAND_ARGS, pListForm); } #endif return true; }
bool Cmd_ListGetNthForm_Execute(COMMAND_ARGS) { *result = 0; BGSListForm* pListForm = NULL; UInt32 n = 0; #if REPORT_BAD_FORMLISTS __try { #endif if (ExtractArgs(EXTRACT_ARGS, &pListForm, &n)) { if (pListForm) { TESForm* pForm = pListForm->GetNthForm(n); if (pForm) { *((UInt32 *)result) = pForm->refID; #if _DEBUG TESFullName* listName = DYNAMIC_CAST(pListForm, BGSListForm, TESFullName); TESFullName* formName = DYNAMIC_CAST(pForm, TESForm, TESFullName); Console_Print("%s item %d: %X %s", listName ? listName->name.m_data : "unknown list", n, pForm->refID, formName ? formName->name.m_data : "unknown item"); #endif } } } #if REPORT_BAD_FORMLISTS } __except(EXCEPTION_EXECUTE_HANDLER) { ReportBadFormlist(PASS_COMMAND_ARGS, pListForm); } #endif return true; }
bool Cmd_ListGetFormIndex_Execute(COMMAND_ARGS) { *result = -1; BGSListForm* pListForm = NULL; TESForm* pForm = NULL; #if REPORT_BAD_FORMLISTS __try { #endif if (ExtractArgs(EXTRACT_ARGS, &pListForm, &pForm)) { if (pListForm && pForm) { SInt32 index = pListForm->GetIndexOf(pForm); *result = index; if (IsConsoleMode()) { Console_Print("Index: %d", index); } } } #if REPORT_BAD_FORMLISTS } __except(EXCEPTION_EXECUTE_HANDLER) { ReportBadFormlist(PASS_COMMAND_ARGS, pListForm); } #endif return true; }
bool Cmd_ListGetCount_Execute(COMMAND_ARGS) { *result = 0; BGSListForm* pListForm = NULL; #if REPORT_BAD_FORMLISTS __try { #endif if (ExtractArgs(EXTRACT_ARGS, &pListForm)) { if (pListForm) { *result = pListForm->Count(); #if _DEBUG Console_Print("count: %d", pListForm->Count()); #endif } } #if REPORT_BAD_FORMLISTS } __except(EXCEPTION_EXECUTE_HANDLER) { ReportBadFormlist(PASS_COMMAND_ARGS, pListForm); } #endif return true; }
static bool Cmd_GetSoundAttenuation_Execute(COMMAND_ARGS) { TESSound* sound = NULL; char whichStr[0x20] = { 0 }; *result = -1.0; if (ExtractArgs(PASS_EXTRACT_ARGS, &sound, whichStr) && sound) { UInt32 which = AttenCodeForString(whichStr); switch (which) { case kAtten_Min: *result = sound->minAttenuation * 5; break; case kAtten_Max: *result = sound->maxAttenuation * 100; break; case kAtten_Static: *result = sound->staticAttenuation / 100.0; break; } } if (IsConsoleMode()) { Console_Print("GetSoundAttenuation >> %.2f", *result); } return true; }
bool Cmd_GetDialogueSpeaker_Eval(COMMAND_ARGS_EVAL) { *result = 0; UInt32* refResult = (UInt32*)result; *refResult = 0; BaseProcess* pProcess = NULL; TESPackage* pPackage = NULL; DialoguePackage* pDPackage = NULL; Actor* pActor = DYNAMIC_CAST(thisObj, TESForm, Actor); if (pActor) pProcess = pActor->baseProcess; if (pProcess) { pPackage = pProcess->GetCurrentPackage(); //DumpClass(pPackage, 128); } if (pPackage) { pDPackage = DYNAMIC_CAST(pPackage, TESPackage, DialoguePackage); if (pDPackage) { if (pDPackage->speaker) *refResult = pDPackage->speaker->refID; } //DEBUG_MESSAGE("\t\tGDK E Actor:%x package:[%#10x] refResult:[%x]\n", pActor->refID, pPackage, *refResult); } if (IsConsoleMode()) Console_Print("GetDialogueSpeaker >> %10X", *refResult); return true; }
bool Cmd_GetCurrentPackage_Execute(COMMAND_ARGS) { *result = 0; UInt32* refResult = (UInt32*)result; *refResult = 0; //DEBUG_MESSAGE("\t\tGCP @\n"); TESObjectREFR* pRefr = NULL; Actor * pActor = NULL; TESPackage* pPackage = NULL; ExtractArgs(EXTRACT_ARGS, &pRefr); if (!pRefr) if(!thisObj) return true; else pRefr = thisObj; //DEBUG_MESSAGE("\t\tGCP 0 Refr:%x\n", pRefr->refID); pActor = DYNAMIC_CAST(pRefr, TESObjectREFR, Actor); if (!pActor || !pActor->baseProcess) return true; //DEBUG_MESSAGE("\t\tGCP 1 Package:[%x] Refr:%x\n", pForm, pRefr->refID); pPackage = pActor->baseProcess->GetCurrentPackage(); //DEBUG_MESSAGE("\t\tGCP 2 Package:[%x] Refr:%x\n", pPackage, pRefr->refID); if (pPackage) { *refResult = pPackage->refID; //DEBUG_MESSAGE("\t\tGCP 3 Package:%x Refr:%x\n", *refResult, pRefr->refID); } if (IsConsoleMode()) Console_Print("GetCurrentPackage >> [%08X] ", *result); return true; }
bool Cmd_NX_GetEVFo_Execute(COMMAND_ARGS) { std::string key; char keyName[512]; float fValue = 0; UInt32 iPersist = 0; _MESSAGE("START GetEVFo"); *result = 0; if (ExtractArgs(EXTRACT_ARGS, &keyName)) { if (thisObj) { key = keyName; *((UInt32 *)result) = nvse_ex_evformmap[thisObj->refID][key]; if (IsConsoleMode()) { Console_Print("GetEVFo: %x", *((UInt32 *)result)); } } } _MESSAGE("END GetEVFo"); return true; }
static bool Cmd_GetCurrentRegions_Execute(COMMAND_ARGS) { ArrayID arrID = g_ArrayMap.Create(kDataType_Numeric, true, scriptObj->GetModIndex()); *result = arrID; TESObjectCELL* cell = (*g_thePlayer)->parentCell; if (cell) { ExtraRegionList* xRegionList = (ExtraRegionList*)cell->extraData.GetByType(kExtraData_RegionList); if (xRegionList && xRegionList->regionList) { double idx = 0.0; for (TESRegionList::Entry* cur = &xRegionList->regionList->regionList; cur && cur->region; cur = cur->next) { g_ArrayMap.SetElementFormID(arrID, idx, cur->region->refID); idx += 1.0; #if _DEBUG Console_Print("Region %08x addr %08x", cur->region->refID, cur->region); #endif } } } return true; }
bool Cmd_ListAddReference_Execute(COMMAND_ARGS) { *result = eListInvalid; BGSListForm* pListForm = NULL; UInt32 n = eListEnd; #if REPORT_BAD_FORMLISTS __try { #endif if (ExtractArgs(EXTRACT_ARGS, &pListForm, &n)) { if (!pListForm || !thisObj) return true; UInt32 index = pListForm->AddAt(thisObj, n); if (index != eListInvalid) { *result = index; } if (IsConsoleMode()) { Console_Print("Index: %d", index); } } #if REPORT_BAD_FORMLISTS } __except(EXCEPTION_EXECUTE_HANDLER) { ReportBadFormlist(PASS_COMMAND_ARGS, pListForm); } #endif return true; }
static bool Cmd_SetDebugMode_Execute(COMMAND_ARGS) { *result = 0; UInt32 bEnableDebug = 0; UInt32 modIndexArg = 0xFFFF; if (!ExtractArgs(PASS_EXTRACT_ARGS, &bEnableDebug, &modIndexArg)) return true; UInt8 modIndex = modIndexArg; if (modIndexArg == 0xFFFF) modIndex = scriptObj->GetModIndex(); if (modIndex > 0 && modIndex < 0xFF) { UInt8 modBit = modIndex % 32; //which bit to toggle //modIndex /= 32; UInt8 bucket = modIndex / 32; //index into bitfield array if (bEnableDebug) ModDebugStates[bucket].Set(1 << modBit); else ModDebugStates[bucket].UnSet(1 << modBit); if (IsConsoleMode()) Console_Print("Debug statements toggled %s for mod %02X", (bEnableDebug ? "on" : "off"), modIndex); } return true; }
bool Accept(char* animName) { Console_Print("%d> %s", index, animName); _MESSAGE("%d> %s", index, animName); ++index; return true; }
bool Cmd_GetGameLoaded_Execute(COMMAND_ARGS) { static std::set<UInt32> informedScripts; *result = 0; // was a game loaded? if(g_gameLoaded) { // yes, clear the list of scripts we've informed and reset the 'game loaded' flag informedScripts.clear(); g_gameLoaded = false; } if(scriptObj) { // have we returned 'true' to this script yet? if(informedScripts.find(scriptObj->refID) == informedScripts.end()) { // no, return true and add to the set *result = 1; informedScripts.insert(scriptObj->refID); } if (IsConsoleMode()) Console_Print("GetGameLoaded >> %.0f", *result); } return true; }
bool Cmd_TestExtractArgsEx_Execute(COMMAND_ARGS) { UInt32 i = 0; char str[0x200] = { 0 }; *result = 0.0; if (ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &i, str)) { Console_Print("TestExtractArgsEx >> int: %d str: %s", i, str); *result = 1.0; } else { Console_Print("TestExtractArgsEx >> couldn't extract arguments"); } return true; }
bool Cmd_GetNthPackage_Execute(COMMAND_ARGS) { *result = 0; UInt32* refResult = (UInt32*)result; TESObjectREFR* pRefr = NULL; TESAIForm* pAI = NULL; TESPackage* pPackage = NULL; SInt32 anIndex = 0; ExtractArgs(EXTRACT_ARGS, &anIndex, &pRefr); if (!pRefr) if(!thisObj) return true; else pRefr = thisObj; //DEBUG_MESSAGE("\t\tGNP 0 Actor:%x index:[%d] package:[%010x]\n", pRefr->refID, anIndex, *result); Actor* pActor = DYNAMIC_CAST(pRefr, TESForm, Actor); if (pActor) pAI = DYNAMIC_CAST(pActor->baseForm, TESForm, TESAIForm); if (pAI) { pPackage = pAI->GetNthPackage(anIndex); if (pPackage) *refResult = pPackage->refID; } if (IsConsoleMode()) Console_Print("GetNthPackage >> %u", *refResult); //DEBUG_MESSAGE("\t\tGNP 1 Actor:%x index:[%d] package:[%010x]\n", pRefr->refID, anIndex, *result); return true; }
bool Cmd_ExamplePlugin_MakeArray_Execute(COMMAND_ARGS) { // Create an array of the format // { // 0:"Zero" // 1:1.0 // 2:PlayerRef // 3:StringMap { "A":"a", "B":123.456, "C":"manually set" } // 4:"Appended" // } // create the inner StringMap array std::map<std::string, OBSEElement> stringMap; stringMap["A"] = "a"; stringMap["B"] = 123.456; // create the outer array std::vector<OBSEElement> vec; vec.push_back("Zero"); vec.push_back(1.0); vec.push_back(*g_thePlayer); // convert our map to an OBSE StringMap and store in outer array OBSEArray* stringMapArr = StringMapFromStdMap(stringMap, scriptObj); vec.push_back(stringMapArr); // manually set another element in stringmap g_arrayIntfc->SetElement(stringMapArr, "C", "manually set"); // convert outer array OBSEArray* arr = ArrayFromStdVector(vec, scriptObj); // append another element to array g_arrayIntfc->AppendElement(arr, "appended"); if (!arr) Console_Print("Couldn't create array"); // return the array if (!g_arrayIntfc->AssignCommandResult(arr, result)) Console_Print("Couldn't assign array to command result."); // result contains the new ArrayID; print it Console_Print("Returned array ID %.0f", *result); return true; }
bool Cmd_GetNVSEBeta_Eval(COMMAND_ARGS_EVAL) { *result = NVSE_VERSION_INTEGER_BETA; if (IsConsoleMode()) { Console_Print("NVSE beta: %d", NVSE_VERSION_INTEGER_BETA); } return true; }
bool Cmd_GetNVSERevision_Eval(COMMAND_ARGS_EVAL) { *result = NVSE_VERSION_INTEGER_MINOR; if (IsConsoleMode()) { Console_Print("NVSE revision: %d", NVSE_VERSION_INTEGER_MINOR); } return true; }
bool Cmd_GetNumLoadedMods_Execute(COMMAND_ARGS) { *result = DataHandler::Get()->GetActiveModCount(); if (IsConsoleMode()) { Console_Print("Mods Loaded: %.0f", *result); } return true; }
bool Cmd_NX_IsUsingSkeleton_Execute(COMMAND_ARGS) { TESActorBase *pActor; char skelName[512]; char actorModel[512]; char *pch = NULL; char *dummy = NULL; char **parts = NULL; int cnt = 0; int idx; _MESSAGE("START IsUsingSkeleton"); *result = 0; if (ExtractArgs(EXTRACT_ARGS, &skelName)) { pActor = DYNAMIC_CAST(thisObj->baseForm, TESForm, TESActorBase); if (pActor) { strcpy_s(actorModel, 512, pActor->model.GetPath()); pch = strtok_s(actorModel, "/\\", &dummy); while (NULL != pch) { parts = (char **) realloc(parts, (cnt + 1) * (sizeof(char*))); parts[cnt] = pch; cnt++; pch = strtok_s(NULL, "/\\", &dummy); } for (idx = 0; idx < cnt; idx++) { _MESSAGE("IDX %d is %s", idx, parts[idx]); } if (cnt >= 2) { _MESSAGE("SIC %s %s is %d", skelName, parts[cnt - 2], _stricmp(skelName, parts[cnt - 2])); if (0 == _stricmp(skelName, parts[cnt - 2])) { *result = 1; } } // Free our memory free(parts); if (IsConsoleMode()) { Console_Print("IsUsingSkeleton %.0f", *result); } } } _MESSAGE("END IsUsingSkeleton %0.0f", *result); return true; }
bool AssignToStringVarLong(COMMAND_ARGS, const char* newValue) { double strID = 0; UInt8 modIndex = 0; bool bTemp = ExpressionEvaluator::Active(); StringVar* strVar = NULL; UInt32 len = (newValue) ? strlen(newValue) : 0; if (!newValue || len >= kMaxMessageLength) //if null pointer or too long, assign an empty string newValue = ""; if (ExtractSetStatementVar(scriptObj, eventList, scriptData, &strID, &modIndex)) { strVar = g_StringMap.Get(strID); bTemp = false; } else if (!bTemp) { _WARNING("Function must be used within a Set statement or NVSE expression"); return false; } if (!modIndex) modIndex = scriptObj->GetModIndex(); if (strVar) { strVar->Set(newValue); g_StringMap.MarkTemporary(strID, false); } else strID = g_StringMap.Add(modIndex, newValue, bTemp); *result = strID; #if _DEBUG // console feedback disabled in release by request (annoying when called from batch scripts) if (IsConsoleMode() && !bTemp) { if (len < 480) Console_Print("Assigned string >> \"%s\"", newValue); else Console_Print("Assigned string (too long to print)"); } #endif return true; }
bool Cmd_GetNumericIniSetting_Execute(COMMAND_ARGS) { char settingName[512] = { 0 }; *result = -1; if (ExtractArgs(EXTRACT_ARGS, &settingName)) { if (GetNumericIniSetting(settingName, result)) { if (IsConsoleMode()) Console_Print("GetNumericIniSetting >> %g", *result); } else if (IsConsoleMode()) Console_Print("GetNumericIniSetting >> SETTING NOT FOUND"); } return true; }
bool Cmd_TestExtractFormatString_Execute(COMMAND_ARGS) { char str[0x200] = { 0 }; int i = 0; TESForm* form = NULL; *result = 0.0; if (ExtractFormatStringArgs(0, str, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, SIZEOF_FMT_STRING_PARAMS + 2, &i, &form)) { Console_Print("TestExtractFormatString >> str: %s int: %d form: %08X", str, i, form ? form->refID : 0); *result = 1.0; } else { Console_Print("TestExtractFormatString >> couldn't extract arguments."); } return true; }
static bool Cmd_GetPCLastDroppedItemRef_Execute(COMMAND_ARGS) { UInt32* refResult = (UInt32*)result; *refResult = GetPCLastDroppedItemRef(); if (IsConsoleMode()) Console_Print("GetPCLastDroppedItemRef >> %08X", *refResult); return true; }
// Implemented in-use functions bool Cmd_NX_GetVersion_Execute(COMMAND_ARGS) { *result = NVSE_EXTENDER_VER; if (IsConsoleMode()) { Console_Print("SEXOUT NVSE version: %d", NVSE_EXTENDER_VER); } return true; }