void Functions::setName(Aurora::NWScript::FunctionContext &ctx) {
	DragonAge::Object *object = DragonAge::ObjectContainer::toObject(getParamObject(ctx, 0));
	if (!object)
		return;

	object->setNonLocalizedName(ctx.getParams()[1].getString());
}
Exemple #2
0
void Area::getEntryLocation(float &posX, float &posY, float &posZ,
                            float &orientX, float &orientY, float &orientZ, float &orientAngle) const {

	DragonAge::Object *object = 0;

	object = ObjectContainer::toObject(_campaign->getFirstObjectByTag(_startPoint));
	if (!object)
		object = ObjectContainer::toObject(_campaign->getFirstObjectByType(kObjectTypeWaypoint));
	if (!object)
		object = ObjectContainer::toObject(_campaign->getFirstObject());

	if (object) {
		object->getPosition(posX, posY, posZ);
		object->getOrientation(orientX, orientY, orientZ, orientAngle);
		return;
	}

	posX = 0.0f;
	posY = 0.0f;
	posZ = 0.0f;

	orientX = 0.0f;
	orientY = 0.0f;
	orientZ = 0.0f;

	orientAngle = 0.0f;
}
void Functions::getNearestObject(Aurora::NWScript::FunctionContext &ctx) {
	Campaign *campaign = _game->getCampaigns().getCurrentCampaign();
	if (!campaign)
		return;

	DragonAge::Object *target = DragonAge::ObjectContainer::toObject(getParamObject(ctx, 0));
	if (!target)
		return;

	// Bitfield of type(s) to check for
	const uint32 type = ctx.getParams()[1].getInt();
	// We want the nth nearest object
	size_t count = MAX<int32>(ctx.getParams()[2].getInt(), 0);

	if (count == 0)
		return;

	Aurora::NWScript::Variable::Array &result = ctx.getReturn().getArray();

	// TODO: nCheckLiving
	// TODO: nCheckPerceived

	const bool includeSelf = ctx.getParams()[5].getInt() != 0;
	if (includeSelf) {
		result.push_back(boost::make_shared<Aurora::NWScript::Variable>(target));
		count--;
	}

	if (count == 0)
		return;

	Aurora::NWScript::ObjectSearch *search = campaign->findObjects();
	Aurora::NWScript::Object       *object = 0;

	std::list<Object *> objects;
	while ((object = search->next())) {
		// Needs to be a valid object and not the target
		DragonAge::Object *daObject = DragonAge::ObjectContainer::toObject(object);
		if (!daObject || (daObject == target))
			continue;

		// Ignore invalid object types
		const uint32 objectType = (uint32) daObject->getType();
		if (objectType >= kObjectTypeMAX)
			continue;

		if (type & objectType)
			objects.push_back(daObject);
	}

	delete search;

	objects.sort(ObjectDistanceSort(*target));

	for (std::list<Object *>::iterator it = objects.begin(); it != objects.end() && count > 0; ++it, count--)
		result.push_back(boost::make_shared<Aurora::NWScript::Variable>(*it));
}
void Functions::getObjectType(Aurora::NWScript::FunctionContext &ctx) {
	ctx.getReturn() = (int32) kObjectTypeInvalid;

	DragonAge::Object *object = DragonAge::ObjectContainer::toObject(getParamObject(ctx, 0));
	if (!object || ((uint32)object->getType() >= kObjectTypeMAX))
		return;

	ctx.getReturn() = (int32) object->getType();
}
Exemple #5
0
void Area::loadObject(DragonAge::Object &object) {
	_objects.push_back(&object);

	_campaign->addObject(object);

	if (!object.isStatic()) {
		const std::list<uint32> &ids = object.getIDs();

		for (std::list<uint32>::const_iterator id = ids.begin(); id != ids.end(); ++id)
			_objectMap.insert(std::make_pair(*id, &object));
	}
}
void Functions::getPosition(Aurora::NWScript::FunctionContext &ctx) {
	ctx.getReturn().setVector(0.0f, 0.0f, 0.0f);

	DragonAge::Object *object = DragonAge::ObjectContainer::toObject(getParamObject(ctx, 0));
	if (!object)
		return;

	float x, y, z;
	object->getPosition(x, y, z);

	ctx.getReturn().setVector(x, y, z);
}
void Functions::UT_getNearestObjectByTag(Aurora::NWScript::FunctionContext &ctx) {
	ctx.getReturn() = (Aurora::NWScript::Object *) 0;

	Campaign *campaign = _game->getCampaigns().getCurrentCampaign();
	if (!campaign)
		return;

	DragonAge::Object *target = DragonAge::ObjectContainer::toObject(getParamObject(ctx, 0));
	if (!target)
		return;

	const Common::UString &tag = ctx.getParams()[1].getString();
	if (tag.empty())
		return;

	const bool includeSelf = ctx.getParams()[2].getInt() != 0;
	if (includeSelf && (target->getTag() == tag)) {
		ctx.getReturn() = (Aurora::NWScript::Object *) target;
		return;
	}

	Aurora::NWScript::ObjectSearch *search = campaign->findObjectsByTag(tag);
	Aurora::NWScript::Object       *object = 0;

	std::list<Object *> objects;
	while ((object = search->next())) {
		// Needs to be a valid object and not the target
		DragonAge::Object *daObject = DragonAge::ObjectContainer::toObject(object);
		if (!daObject || (daObject == target))
			continue;

		objects.push_back(daObject);
	}

	delete search;

	objects.sort(ObjectDistanceSort(*target));

	if (!objects.empty())
		ctx.getReturn() = (Aurora::NWScript::Object *) *objects.begin();
}