Exemple #1
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;
}
static bool Cmd_SetHair_Execute(COMMAND_ARGS)
{
	TESForm* form = NULL;
	TESForm*  npcF = NULL;
	*result = 0;

	ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &form, &npcF);
	if (!form)
		return true;

	TESHair* hair = (TESHair*)Oblivion_DynamicCast(form, 0, RTTI_TESForm, RTTI_TESHair, 0);
	if (!hair)
		return true;
	else if (!npcF)
	{
		if (!thisObj)
			return true;
		npcF = thisObj->baseForm;
	}

	TESNPC* npc = (TESNPC*)Oblivion_DynamicCast(npcF, 0, RTTI_TESForm, RTTI_TESNPC, 0);

	if (!npc)
		return true;
	npc->hair = hair;

	*result = 1;
	return true;
}
static bool GetScript_Execute(COMMAND_ARGS, EScriptMode eMode)
{
	*result = 0;
	TESForm* form = 0;

	ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &form);
	form = form->TryGetREFRParent();
	if (!form) {
		if (!thisObj) return true;
		form = thisObj->baseForm;
	}

	TESScriptableForm* scriptForm = (TESScriptableForm*)Oblivion_DynamicCast(form, 0, RTTI_TESForm, RTTI_TESScriptableForm, 0);
	Script* script = (scriptForm) ? scriptForm->script : NULL;

	if (eMode == eScript_HasScript) {
		*result = (script != NULL) ? 1 : 0;
	} else {
		if (script) {
			UInt32* refResult = (UInt32*)result;
			*refResult = script->refID;		
		}
		if (eMode == eScript_Remove) {
			scriptForm->script = NULL;
		}
	}

	return true;
}
bool Cmd_GetScopeModelPath_Execute(COMMAND_ARGS)
{
	TESForm* form = NULL;
	TESModel* model = NULL;
	const char* pathStr = "";
	*result = 0;

	if (ExtractArgsEx(EXTRACT_ARGS_EX, &form))
	{
		if (!form)
			if (thisObj)
				form = thisObj->baseForm;

		TESObjectWEAP* weapon = DYNAMIC_CAST(form, TESForm, TESObjectWEAP);
		if (weapon && weapon->HasScope())
			model = &(weapon->targetNIF);

		if (model)
			pathStr = model->nifPath.m_data;
	}

	AssignToStringVar(PASS_COMMAND_ARGS, pathStr);

	return true;
}
bool Cmd_AddPackageAt_Execute(COMMAND_ARGS)
{
	*result = 0;
	TESForm* pForm;
	TESObjectREFR* pRefr = NULL;
	TESAIForm* pAI = NULL;
	TESPackage* pPackage = NULL;
	SInt32 anIndex = 0;

	ExtractArgsEx(EXTRACT_ARGS_EX, &pForm, &anIndex, &pRefr);
	if (!pRefr)
		if(!thisObj)
			return true;
		else
			pRefr = thisObj;

	//DEBUG_MESSAGE("\t\tAPA 0 Actor:%x index:[%d] result:[%d]\n", pRefr->refID, anIndex, *result);
	Actor* pActor = DYNAMIC_CAST(pRefr, TESForm, Actor);
	if (pActor)
		pAI = DYNAMIC_CAST(pActor->baseForm, TESForm, TESAIForm);
	//DEBUG_MESSAGE("\t\tAPA 1 Actor:%x index:[%d] AI:[%x]\n", pRefr->refID, anIndex, pAI);
	if (pAI)
		pPackage = DYNAMIC_CAST(pForm, TESForm, TESPackage);
	//DEBUG_MESSAGE("\t\tAPA 2 Actor:%x index:[%d] Package:[%x]\n", pRefr->refID, anIndex, pPackage);
	if (pPackage) 
		*result = pAI->AddPackageAt(pPackage, anIndex);
	//DEBUG_MESSAGE("\t\tAPA 3 Actor:%x index:[%d] result:[%d]\n", pRefr->refID, anIndex, *result);
	return true;
}
bool GetPath_Execute(COMMAND_ARGS, UInt32 whichPath)
{
	TESForm* form = NULL;
	const char* pathStr = "";

	if (ExtractArgsEx(EXTRACT_ARGS_EX, &form))
	{
		if (form)
			form = form->TryGetREFRParent();
		if (!form)
			if (thisObj)
				form = thisObj->baseForm;
		switch (whichPath) {
			case kPath_Icon:
				{
					TESIcon* icon = DYNAMIC_CAST(form, TESForm, TESIcon);
					if (icon)
						pathStr = icon->ddsPath.m_data;
				}
				break;
			case kPath_Texture:
				{
					TESTexture* tex = DYNAMIC_CAST(form, TESForm, TESTexture);
					if (tex)
						pathStr = tex->ddsPath.m_data;
				}
				break;
		}
	}

	AssignToStringVarLong(PASS_COMMAND_ARGS, pathStr);
	return true;
}
static bool Cmd_SetScript_Execute(COMMAND_ARGS)
{
	*result = 0;
	UInt32* refResult = (UInt32*)result;

	TESForm* form = NULL;
	TESForm* scriptArg = NULL;

	ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &scriptArg, &form);
	form = form->TryGetREFRParent();
	if (!form) {
		if (!thisObj) return true;
		form = thisObj->baseForm;
	}

	TESScriptableForm* scriptForm = (TESScriptableForm*)Oblivion_DynamicCast(form, 0, RTTI_TESForm, RTTI_TESScriptableForm, 0);
	if (!scriptForm) return true;

	Script* script = (Script*)Oblivion_DynamicCast(scriptArg, 0, RTTI_TESForm, RTTI_Script, 0);
	if (!script) return true;

	// we can't get a magic script here
	if (script->IsMagicScript()) return true;

	if (script->IsQuestScript() && form->typeID == kFormType_Quest) {
		*refResult = scriptForm->script->refID;
		scriptForm->script = script;
	} else if (script->IsObjectScript()) {
		if (scriptForm->script) {
			*refResult = scriptForm->script->refID;
		}
		scriptForm->script = script;
	}
	return true;
}
Exemple #8
0
bool Cmd_ListRemoveForm_Execute(COMMAND_ARGS)
{
	*result = 0;
	BGSListForm* pListForm = NULL;
	TESForm* pForm = NULL;

#if REPORT_BAD_FORMLISTS
	__try {
#endif

	ExtractArgsEx(EXTRACT_ARGS_EX, &pListForm, &pForm);
	if (pListForm && pForm) {
		SInt32 index = pListForm->RemoveForm(pForm);
		*result = index;
	}

#if REPORT_BAD_FORMLISTS
	} __except(EXCEPTION_EXECUTE_HANDLER)
	{
		ReportBadFormlist(PASS_COMMAND_ARGS, pListForm);
	}
#endif

	return true;
}
static bool Cmd_IsFormValid_Execute(COMMAND_ARGS)
{
	TESForm* form = NULL;
	*result = 0;
	if (ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &form) && form)
		*result = 1;
	return true;
}
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_GetFormIDString_Execute(COMMAND_ARGS)
{
	TESForm* form = NULL;
	ExtractArgsEx(EXTRACT_ARGS_EX, &form);
	if (!form)
		form = thisObj;

	UInt32 formID = form ? form->refID : 0;
	char str[0x20] = { 0 };
	sprintf_s(str, sizeof(str), "%08X", formID);
	AssignToStringVar(PASS_COMMAND_ARGS, str);
	return true;
}
static bool Cmd_SetCellWaterType_Execute(COMMAND_ARGS)
{
	TESObjectCELL* cell = NULL;
	TESForm* waterForm = NULL;
	if (ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &cell, &waterForm) && cell && waterForm) {
		TESWaterForm* water = OBLIVION_CAST(waterForm, TESForm, TESWaterForm);
		if (water) {
			cell->SetWaterType(water);
		}
	}

	return true;
}
Exemple #13
0
static bool Cmd_SetTextInputControlHandler_Execute(COMMAND_ARGS)
{
	TESForm* scriptForm = NULL;
	TextInputHandler* textBox = TextInputHandler::GetTextBox();
	if (textBox && ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &scriptForm)) {
		Script* script = OBLIVION_CAST(scriptForm, TESForm, Script);
		if (script) {
			textBox->SetControlHandler(script);
		}
	}

	return true;
}
static bool Cmd_IsKeyPressed3_Execute(COMMAND_ARGS)
{
	*result = 0;
	UINT keyCode = NOKEY;
	//if (!ExtractArgs(paramInfo, arg1, opcodeOffsetPtr, thisObj, arg3, scriptObj, eventList, &keyCode))
	if (!ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &keyCode))
	{
		return true;
	}

	if (_isKeyPressed(keyCode))	*result = 1;

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

	UInt32	modIdx, refIdx;

	if(!ExtractArgsEx(EXTRACT_ARGS_EX, &modIdx, &refIdx))
		return true;

	*refResult = ((modIdx & 0xFF) << 24) | (refIdx & 0x00FFFFFF);

	return true;
}
Exemple #16
0
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;
}
static bool Cmd_GetNthSpell_Execute(COMMAND_ARGS)
{
	UInt32	* refResult = (UInt32 *)result;
	*refResult = 0;

	TESForm* baseForm = (thisObj) ? thisObj->baseForm : (*g_thePlayer)->baseForm;
	TESSpellList* spellList = (TESSpellList *)Oblivion_DynamicCast(baseForm, 0, RTTI_TESForm, RTTI_TESSpellList, 0);
	if (!spellList) return true;

	UInt32 whichSpell = 0;
	if(!ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &whichSpell)) return true;

	TESForm* spellForm = spellList->GetNthSpell(whichSpell);
	if (spellForm) {
		*refResult = spellForm->refID;
	}
	return true;
}
// This works for any TESFullName-derived form as well as references
bool Cmd_GetName_Execute(COMMAND_ARGS)
{
	TESForm* form = NULL;
	const char* name = "";

	if (ExtractArgsEx(EXTRACT_ARGS_EX, &form))
	{
		if (!form)
			if (thisObj)
				form = thisObj;

		if (form)
			name = GetFullName(form);
	}

	AssignToStringVar(PASS_COMMAND_ARGS, name);
	return true;
}
bool Cmd_GetLocalRefIndex_Execute(COMMAND_ARGS)
{
	TESForm* form = NULL;
	*result = -1;

	if (!ExtractArgsEx(EXTRACT_ARGS_EX, &form))
		return true;

	if (!form)
		form = thisObj;

	if (form)
	{
		*result = form->refID & 0x00FFFFFF;
	}

	return true;
}
bool Cmd_GetNthEffectItemScriptName_Execute(COMMAND_ARGS)
{
	TESForm* form = NULL;
	UInt32 whichEffect = 0;
	const char* effectName = "";

	if (ExtractArgsEx(EXTRACT_ARGS_EX, &form, &whichEffect))
	{
		EffectItemList* effectList = GetEffectList(form);
		if (effectList)
		{
			EffectItem* effectItem = effectList->ItemAt(whichEffect);
			if (effectItem && effectItem->scriptEffectInfo)
				effectName = effectItem->scriptEffectInfo->effectName.m_data;
		}
	}

	AssignToStringVar(PASS_COMMAND_ARGS, effectName);
	return true;
}
Exemple #21
0
static bool Cmd_GetRaceReaction_Execute(COMMAND_ARGS)
{
	*result = 0;

	TESRace* pFromRace = NULL;
	TESRace* pToRace = NULL;
	bool bExtracted = ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &pToRace, &pFromRace);
	if (!pToRace) return true;
	if (!pFromRace) {
		if (!thisObj) return true;
		TESNPC* npc = (TESNPC*)Oblivion_DynamicCast(thisObj->baseForm, 0, RTTI_TESForm, RTTI_TESNPC, 0);
		if (!npc) return true;
		pFromRace = npc->race.race;
		if (!pFromRace) return true;
	}

	SInt32 reaction = pFromRace->reaction.ReactionFor(pToRace);
	*result = reaction;
	return true;
}
static bool Cmd_CompareScripts_Execute(COMMAND_ARGS)
{
	Script* script1 = NULL;
	Script* script2 = NULL;
	*result = 0;

	if (!ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &script1, &script2))
		return true;
	script1 = (Script*)Oblivion_DynamicCast(script1, 0, RTTI_TESForm, RTTI_Script, 0);
	script2 = (Script*)Oblivion_DynamicCast(script2, 0, RTTI_TESForm, RTTI_Script, 0);

	if (script1 && script2 && script1->info.dataLength == script2->info.dataLength)
	{
		if (script1 == script2)
			*result = 1;
		else if (!memcmp(script1->data, script2->data, script1->info.dataLength))
			*result = 1;
	}

	return true;
}
bool Cmd_GetSourceModIndex_Execute(COMMAND_ARGS)
{
	TESForm* form = NULL;
	*result = -1;

	if (!ExtractArgsEx(EXTRACT_ARGS_EX, &form))
		return true;

	if (!form)
		form = thisObj;
	
	if (form)
	{
		if (form->IsCloned())
			*result = 0xFF;
		else
			*result = (UInt8)(form->refID >> 24);
	}

	return true;
}
bool Cmd_GetModelPath_Execute(COMMAND_ARGS)
{
	TESForm* form = NULL;
	const char* pathStr = "";
	*result = 0;

	if (ExtractArgsEx(EXTRACT_ARGS_EX, &form))
	{
		if (form)
			form = form->TryGetREFRParent();
		if (!form)
			if (thisObj)
				form = thisObj->baseForm;

		TESModel* model = DYNAMIC_CAST(form, TESForm, TESModel);
		if (model)
			pathStr = model->nifPath.m_data;
	}

	AssignToStringVar(PASS_COMMAND_ARGS, pathStr);
	return true;
}
bool Cmd_SetScopeModelPath_Execute(COMMAND_ARGS)
{
	TESForm* form = NULL;
	TESModel* model = NULL;
	char pathStr[512];
	*result = 0;

	if (ExtractArgsEx(EXTRACT_ARGS_EX, &pathStr, &form))
	{
		if (!form)
			if (thisObj)
				form = thisObj->baseForm;

		TESObjectWEAP* weapon = DYNAMIC_CAST(form, TESForm, TESObjectWEAP);
		if (weapon && weapon->HasScope())
			model = &(weapon->targetNIF);

		if (model)
			model->nifPath.Set(pathStr);
	}

	return true;
}
bool BipedPathFunc_Execute(COMMAND_ARGS, UInt32 mode, bool bIcon)
{
	UInt32 whichPath = 0;
	TESForm* form = NULL;
	const char* pathStr = "";
	char newPath[kMaxMessageLength] = { 0 };

	bool bExtracted = false;
	if (mode == eMode_Set)
		bExtracted = ExtractFormatStringArgs(0, newPath, PASS_FMTSTR_ARGS, kCommandInfo_SetBipedModelPathEX.numParams, &whichPath, &form);
	else
		bExtracted = ExtractArgsEx(EXTRACT_ARGS_EX, &whichPath, &form);

	if (bExtracted)
	{
		if (!form)
			if (thisObj)
				form = thisObj->baseForm;

		TESBipedModelForm* bipedModel = DYNAMIC_CAST(form, TESForm, TESBipedModelForm);
		if (bipedModel)
		{
			bool bFemale = (whichPath % 2) ? true : false;
			whichPath = bIcon ? bipedModel->ePath_Icon : whichPath / 2;

			if (mode == eMode_Set)
				bipedModel->SetPath(newPath, whichPath, bFemale);
			else
				pathStr = bipedModel->GetPath(whichPath, bFemale);
		}
	}

	if (mode == eMode_Get)
		AssignToStringVarLong(PASS_COMMAND_ARGS, pathStr);

	return true;
}
// this command can have unpredictable results if used on an actor reference whose base form is not unique
// It copies the race from another NPC rather than accepting a race directly, because it needs to change the skeleton path
static bool Cmd_CopyRace_Execute(COMMAND_ARGS)
{
	TESNPC* npc = NULL;
	TESForm* fromArg = NULL;

	if (thisObj)
		npc = (TESNPC*)Oblivion_DynamicCast(thisObj->baseForm, 0, RTTI_TESForm, RTTI_TESNPC, 0);

	if (!npc)
		return true;

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

	TESNPC* fromNPC = (TESNPC*)Oblivion_DynamicCast(fromArg, 0, RTTI_TESForm, RTTI_TESNPC, 0);
	if (!fromNPC)
		return true;

	npc->race.race = fromNPC->race.race;
	npc->model.SetModelPath (fromNPC->model.GetModelPath ());
	thisObj->Update3D ();

	return true;
}
Exemple #28
0
bool Cmd_ExamplePlugin_0019Additions_Execute(COMMAND_ARGS)
{
	// tests and demonstrates 0019 additions to plugin API
	// args:
	//	an array ID as an integer
	//	a function script with the signature {int, string, refr} returning a string
	// return:
	//	an array containing the keys and values of the original array

	UInt32 arrID = 0;
	TESForm* funcForm = NULL;

	if (ExtractArgsEx(paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, &arrID, &funcForm)) {

		// look up the array
		 OBSEArray* arr = g_arrayIntfc->LookupArrayByID(arrID);
		 if (arr) {
			 // get contents of array
			 UInt32 size = g_arrayIntfc->GetArraySize(arr);
			 if (size != -1) {
				 OBSEElement* elems = new OBSEElement[size];
				 OBSEElement* keys = new OBSEElement[size];

				 if (g_arrayIntfc->GetElements(arr, elems, keys)) {
					 OBSEArray* newArr = g_arrayIntfc->CreateArray(NULL, 0, scriptObj);
					 for (UInt32 i = 0; i < size; i++) {
						 g_arrayIntfc->SetElement(newArr, i*2, elems[i]);
						 g_arrayIntfc->SetElement(newArr, i*2+1, keys[i]);
					 }

					 // return the new array
					 g_arrayIntfc->AssignCommandResult(newArr, result);
				 }

				 delete[] elems;
				 delete[] keys;

			 }
		 }

		 if (funcForm) {
			 Script* func = OBLIVION_CAST(funcForm, TESForm, Script);
			 if (func) {
				 // call the function
				 OBSEElement funcResult;
				 if (g_scriptIntfc->CallFunction(func, thisObj, NULL, &funcResult, 3, 123456, "a string", *g_thePlayer)) {
					 if (funcResult.GetType() == funcResult.kType_String) {
						 Console_Print("Function script returned string %s", funcResult.String());
					 }
					 else {
						 Console_Print("Function did not return a string");
					 }
				 }
				 else {
					 Console_Print("Could not call function script");
				 }
			 }
			 else {
				 Console_Print("Could not extract function script argument");
			 }
		 }
	}

	return true;
}