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;
}
Exemple #4
0
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;
}
Exemple #5
0
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;
}
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;
}
Exemple #7
0
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;
}
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_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;
}
Exemple #10
0
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;
}
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_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;
}
Exemple #13
0
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;
}
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_GetNumLoadedMods_Execute(COMMAND_ARGS)
{
	*result = DataHandler::Get()->GetActiveModCount();
	if (IsConsoleMode()) {
		Console_Print("Mods Loaded: %.0f", *result);
	}
	return true;
}
Exemple #16
0
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;
}
Exemple #17
0
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;
}
Exemple #18
0
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 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;
}
Exemple #20
0
// 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;
}
// core commands
static void PrintVersion(void)
{
	if(IsConsoleMode())
	{
		Console_Print("SKSE version: %d.%d.%d, release idx %d, runtime %08X",
			SKSE_VERSION_INTEGER, SKSE_VERSION_INTEGER_MINOR, SKSE_VERSION_INTEGER_BETA,
			SKSE_VERSION_RELEASEIDX, RUNTIME_VERSION);
	}
}
static bool Cmd_GetPCLastDroppedItemRef_Execute(COMMAND_ARGS)
{
	UInt32* refResult = (UInt32*)result;
	*refResult = GetPCLastDroppedItemRef();
	if (IsConsoleMode())
		Console_Print("GetPCLastDroppedItemRef >> %08X", *refResult);

	return true;
}
bool Cmd_GetBaseObject_Execute(COMMAND_ARGS)
{
	UInt32* refResult = (UInt32*)result;
	*refResult = 0;

	if (thisObj && thisObj->baseForm) {
		*refResult = thisObj->baseForm->refID;
		if (IsConsoleMode())
			Console_Print("GetBaseObject >> %08x (%s)", thisObj->baseForm->refID, GetFullName(thisObj->baseForm));
	}
	return true;
}
const char GetSeparatorChar(Script* script)
{
	if (IsConsoleMode())
	{
		if (script && script->GetModIndex() != 0xFF)
			return '|';
		else
			return '@';
	}
	else
		return '|';
}
const char* GetSeparatorChars(Script* script)
{
	if (IsConsoleMode())
	{
		if (script && script->GetModIndex() != 0xFF)
			return "|";
		else
			return "@";
	}
	else
		return "|";
}
static bool Cmd_PlayIdle_Execute(COMMAND_ARGS)
{
	UInt32 bForceIdle = 0;
	Actor* callingActor = NULL;
	TESForm* idleForm = NULL;
	*result = 0;

	if (!ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &idleForm, &bForceIdle))
		return true;

	switch (thisObj->typeID)
	{
	case kFormType_ACHR:
	case kFormType_ACRE:
		callingActor = OBLIVION_CAST(thisObj, TESObjectREFR, Actor);
		break;
	default:
		return true;
	}

	if (callingActor->process)
	{
		TESIdleForm* idle = OBLIVION_CAST(idleForm, TESForm, TESIdleForm);

		if (idle && idle->animModel.nifPath.m_data)
		{
			std::string str(idle->animModel.nifPath.m_data);
			if (str.find(".kf") != std::string::npos)
			{
				ActorAnimData* animData = (ActorAnimData*)ThisVirtualStdCall(0x00A6E074, 0x164, callingActor);
				if (animData)
				{						// ### TODO expose the gunk that follows
					if (!animData->unkC8[2] || (UInt32)animData->niNodes24[0] != (UInt32)idle)
					{
						UInt32 unk01 = animData->unkC8[1], unk02 = unk01 + 0x10, unk03 = ThisStdCall(0x00472EA0, animData);

						if (bForceIdle || !unk03 || (unk01 && (*((UInt32*)unk01 + 4) != 3 || (*((UInt32*)unk02) && !((UInt32*)unk02 + 0x24)))))
						{
							ThisStdCall(0x00477DB0, animData, idle, callingActor, (idle->animFlags & 0x7F), 3); // ActorAnimData::QueueIdle (probably)
							if (IsConsoleMode()) {
								Console_Print("PlayIdle >> %s on %08X", idle->animModel.nifPath.m_data, idle->refID);
							}
							*result = 1;
						}
					}
				}
			}
		}
	}

	return true;
}
bool Cmd_GetModIndex_Execute(COMMAND_ARGS)
{
	char modName[512];
	if (!ExtractArgs(EXTRACT_ARGS, &modName))
		return true;

	UInt32 modIndex = DataHandler::Get()->GetModIndex(modName);
	*result = modIndex;
	if (IsConsoleMode())
		Console_Print("Mod Index: %02X", modIndex);

	return true;
}
bool Cmd_GetBaseForm_Execute(COMMAND_ARGS)	// For LeveledForm, find real baseForm, not temporary one
{
	UInt32* refResult = (UInt32*)result;
	*refResult = 0;
	TESForm* baseForm = GetPermanentBaseForm(thisObj);

	if (baseForm) {
		*refResult = baseForm->refID;
		if (IsConsoleMode())
			Console_Print("GetBaseForm >> %08x (%s)", baseForm->refID, GetFullName(baseForm));
	}
	return true;
}
static bool Cmd_GetPCAttributeBonus_Execute(COMMAND_ARGS)
{
	UInt32 whichAttribute = 0;
	*result = 0;

	if (ExtractArgs(EXTRACT_ARGS, &whichAttribute))
	{
		*result = (*g_thePlayer)->GetAttributeBonus(whichAttribute);
		if (IsConsoleMode())
			Console_Print("GetPCAttributeBonus >> %.0f", *result);
	}
	return true;
}
static bool Cmd_GetCurrentRegion_Execute(COMMAND_ARGS)
{
	UInt32* refResult = (UInt32*)result;
	*refResult = 0;
	TESRegion* region = (*g_thePlayer)->region;
	if (region)
		*refResult = region->refID;

	if (IsConsoleMode())
		Console_Print("GetCurrentRegion >> %08X", (region ? region->refID : 0));

	return true;
}