예제 #1
0
static bool Cmd_GetFactions_Execute(COMMAND_ARGS)
{
	class Counter {
	public:
		Counter(ArrayID arrID) : m_arrID(arrID), m_curIndex(0) { }

		bool Accept(const TESActorBaseData::FactionListData* entry) {
			if (entry == NULL)
				return false;

			g_ArrayMap.SetElementFormID(m_arrID, m_curIndex++, entry->faction->refID);
			return true;
		}
	private:
		ArrayID m_arrID;
		UInt32	m_curIndex;
	};

	TESActorBase* actor = NULL;
	ArrayID arr = g_ArrayMap.Create(kDataType_Numeric, true, scriptObj->GetModIndex());
	*result = arr;

	if (ExtractArgs(PASS_EXTRACT_ARGS, &actor)) {
		if (actor == NULL && thisObj && (thisObj->baseForm->typeID == kFormType_Creature || thisObj->baseForm->typeID == kFormType_NPC))
			actor = OBLIVION_CAST(thisObj->baseForm, TESForm, TESActorBase);
		
		if (actor)	{
			FactionListVisitor(&actor->actorBaseData.factionList).Visit(Counter(arr));
		}
	}

	return true;
}
예제 #2
0
static bool Cmd_GetNumFactions_Execute(COMMAND_ARGS)
{
	*result = 0;
	TESActorBase* actorBase = ExtractActorBase(PASS_COMMAND_ARGS);
	if (actorBase)
	{
		*result = FactionListVisitor(&(actorBase->actorBaseData.factionList)).Count();
	}

	return true;
}
예제 #3
0
static bool Cmd_GetNthFaction_Execute(COMMAND_ARGS)
{
	UInt32 factionIdx = 0;
	UInt32* refResult = (UInt32*)result;
	*refResult = 0;

	TESActorBase* actorBase = ExtractSetActorBase(PASS_COMMAND_ARGS, &factionIdx);
	if (actorBase)
	{
		TESActorBaseData::FactionListData* data = FactionListVisitor(&(actorBase->actorBaseData.factionList)).GetNthInfo(factionIdx);
		if (data)
			*refResult = data->faction->refID;
	}

	return true;
}