Ejemplo n.º 1
0
void Functions::actionJumpToObject(Aurora::NWScript::FunctionContext &ctx) {
	// TODO: walkStraightLineToPoint
	// bool walkStraightLineToPoint = ctx.getParams()[1].getInt() != 0;

	NWN2::Object *object = NWN2::ObjectContainer::toObject(ctx.getCaller());
	NWN2::Object *moveTo = NWN2::ObjectContainer::toObject(getParamObject(ctx, 0));

	if (!object || !moveTo)
		return;

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

	jumpTo(object, moveTo->getArea(), x, y, z);
}
Ejemplo n.º 2
0
void Functions::getDistanceToObject(Aurora::NWScript::FunctionContext &ctx) {
	ctx.getReturn() = -1.0f;

	NWN2::Object *object1 = NWN2::ObjectContainer::toObject(getParamObject(ctx, 0));
	NWN2::Object *object2 = NWN2::ObjectContainer::toObject(ctx.getCaller());
	if (!object1 || !object2)
		return;

	float x1, y1, z1;
	object1->getPosition(x1, y1, z1);

	float x2, y2, z2;
	object2->getPosition(x2, y2, z2);

	ctx.getReturn() = sqrtf(SQR(x1 - x2) + SQR(y1 - y2) + SQR(z1 - z2));
}
Ejemplo n.º 3
0
void Functions::actionMoveToLocation(Aurora::NWScript::FunctionContext &ctx) {
	// TODO: runType
	// int32 runType = ctx.getParams()[1].getInt();
	// int32 moveAnim = ctx.getParams()[2].getInt();

	Jade::Object   *object = Jade::ObjectContainer::toObject(ctx.getCaller());
	Jade::Location *moveTo = Jade::ObjectContainer::toLocation(ctx.getParams()[0].getEngineType());

	if (!object || !moveTo)
		return;

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

	jumpTo(object, moveTo->getArea(), x, y, z);

	unimplementedFunction(ctx);
}
Ejemplo n.º 4
0
void Functions::beginConversation(Aurora::NWScript::FunctionContext &ctx) {
	ctx.getReturn() = 0;

	// Get the script object parameters
	Aurora::NWScript::Object *obj1 = ctx.getCaller();
	Aurora::NWScript::Object *obj2 = getParamObject(ctx, 1);
	if (!obj2)
		obj2 = ctx.getTriggerer();
	if (!obj2)
		obj2 = _game->getModule().getPC();

	// Try to convert them to an NWN Creature and Object
	NWN::Creature *pc     = NWN::ObjectContainer::toPC(obj2);
	NWN::Object   *object = NWN::ObjectContainer::toObject(obj1);

	// Try the other way round, if necessary
	if (!pc || !object) {
		pc     = NWN::ObjectContainer::toPC(obj1);
		object = NWN::ObjectContainer::toObject(obj2);
	}

	// Fail
	if (!pc || !object)
		return;

	if (object->getPCSpeaker()) {
		if (object->getPCSpeaker() != pc) {
			Creature *otherPC = NWN::ObjectContainer::toPC(object->getPCSpeaker());

			warning("Functions::beginConversation(): "
			        "Object \"%s\" already in conversation with PC \"%s\"",
			        object->getTag().c_str(), otherPC ? otherPC->getName().c_str() : "");
			return;
		}
	}

	Common::UString conversation = ctx.getParams()[0].getString();
	if (conversation.empty())
		conversation = object->getConversation();

	ctx.getReturn() = _game->getModule().startConversation(conversation, *pc, *object);
}
Ejemplo n.º 5
0
void Functions::actionStartConversation(Aurora::NWScript::FunctionContext &ctx) {
	Jade::Object *source = Jade::ObjectContainer::toObject(ctx.getCaller());
	Jade::Object *target = Jade::ObjectContainer::toObject(getParamObject(ctx, 0));
	if (!source || !target)
		return;

	Creature *pc = Jade::ObjectContainer::toPC(target);
	if (!pc) {
		warning("TODO: ActionStartConversation: Non-PC target \"%s\"", target->getTag().c_str());
		return;
	}

	if (source->getPCSpeaker()) {
		if (source->getPCSpeaker() != pc) {
			Creature *otherPC = Jade::ObjectContainer::toPC(source->getPCSpeaker());

			warning("Functions::actionStartConversation(): "
			        "Object \"%s\" already in conversation with PC \"%s\"",
			        source->getTag().c_str(), otherPC ? otherPC->getName().c_str() : "");
			return;
		}
	}

	Common::UString conversation = ctx.getParams()[1].getString();
	if (conversation.empty())
		conversation = source->getConversation();

	/* TODO
	const int32 range = ctx.getParams()[2].getInt();
	const int32 delay = ctx.getParams()[3].getInt();
	const bool ignoreLOS = ctx.getParams()[4].getInt() != 0;
	*/
	const bool noWidescreen = ctx.getParams()[5].getInt() != 0;
	const bool resetZoom = ctx.getParams()[6].getInt() != 0;

	_game->getModule().startConversation(conversation, *pc, *source, noWidescreen, resetZoom);
}
Ejemplo n.º 6
0
void Functions::actionSpeakStringByStrRef(Aurora::NWScript::FunctionContext &ctx) {
	Jade::Object *object = Jade::ObjectContainer::toObject(ctx.getCaller());

	if (object)
		object->speakString(ctx.getParams()[0].getInt());
}
Ejemplo n.º 7
0
void Functions::actionCloseDoor(Aurora::NWScript::FunctionContext &ctx) {
	Placeable *door = Jade::ObjectContainer::toPlaceable(getParamObject(ctx, 0));
	if (door)
		door->close(Jade::ObjectContainer::toObject(ctx.getCaller()));
}
Ejemplo n.º 8
0
void Functions::actionSpeakString(Aurora::NWScript::FunctionContext &ctx) {
	NWN::Object *object = NWN::ObjectContainer::toObject(ctx.getCaller());

	if (object)
		object->speakString(ctx.getParams()[0].getString(), ctx.getParams()[1].getInt());
}
Ejemplo n.º 9
0
void Functions::actionCloseDoor(Aurora::NWScript::FunctionContext &ctx) {
	Door *door = NWN::ObjectContainer::toDoor(getParamObject(ctx, 0));
	if (door)
		door->close(NWN::ObjectContainer::toObject(ctx.getCaller()));
}
Ejemplo n.º 10
0
void Functions::actionOpenDoor(Aurora::NWScript::FunctionContext &ctx) {
	Door *door = Witcher::ObjectContainer::toDoor(getParamObject(ctx, 0));
	if (door)
		door->open(Witcher::ObjectContainer::toObject(ctx.getCaller()));
}