Exemplo n.º 1
0
void Lua_V2::PlayActorChore() {
	lua_Object actorObj = lua_getparam(1);
	lua_Object choreObj = lua_getparam(2);
	lua_Object costumeObj = lua_getparam(3);
//	lua_Object modeObj = lua_getparam(4);
//	lua_Object paramObj = lua_getparam(5);

	if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
		return;

	Actor *actor = getactor(actorObj);

	if (!lua_isstring(choreObj) || !lua_isstring(costumeObj))
		lua_pushnil();

/*	bool mode = false;
	float param = 0.0;

	if (!lua_isnil(modeObj)) {
		if (lua_getnumber(modeObj) != 0.0)
			mode = true;
		if (!lua_isnil(paramObj))
			if (lua_isnumber(paramObj))
				param = lua_getnumber(paramObj);
	}*/

	const char *choreName = lua_getstring(choreObj);
	const char *costumeName = lua_getstring(costumeObj);
	Costume *costume = actor->findCostume(costumeName);

	if (costume == NULL) {
		actor->pushCostume(costumeName);
		costume = actor->findCostume(costumeName);
	}

	PoolChore *chore = (PoolChore *)costume->getChore(choreName);
	costume->playChore(choreName);
	if (chore) {
		lua_pushusertag(chore->getId(), MKTAG('C','H','O','R'));
	} else {
		lua_pushnil();
	}

}
Exemplo n.º 2
0
static void L2_PlayActorChore() {
	lua_Object actorObj = lua_getparam(1);
	lua_Object choreObj = lua_getparam(2);
	lua_Object costumeObj = lua_getparam(3);
	lua_Object modeObj = lua_getparam(4);
	lua_Object paramObj = lua_getparam(5);

	if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
		return;

	Actor *actor = getactor(actorObj);

	if (!lua_isstring(choreObj) || !lua_isstring(costumeObj))
		lua_pushnil();

	bool mode = false;
	float param = 0.0;

	if (!lua_isnil(modeObj)) {
		if (lua_getnumber(modeObj) != 0.0)
			mode = true;
		if (!lua_isnil(paramObj))
			if (lua_isnumber(paramObj))
				param = lua_getnumber(paramObj);
	}

	const char *choreName = lua_getstring(choreObj);
	const char *costumeName = lua_getstring(costumeObj);

	warning("L2_PlayActorChore: implement opcode actor: %s, chore: %s, costume: %s, mode bool: %d, param: %f",
			actor->getName().c_str(), choreName, costumeName, (int)mode, param);
	// FIXME. code below is a hack, need proper implementation
	actor->setCostume(costumeName);
	Costume *costume = actor->getCurrentCostume();
	costume->playChore(choreName);
	pushbool(true);
}
Exemplo n.º 3
0
// TODO: Implement, verify, and rename unknown 5th parameter
void Lua_V2::PlayActorChore() {
	lua_Object actorObj = lua_getparam(1);
	lua_Object choreObj = lua_getparam(2);
	lua_Object costumeObj = lua_getparam(3);
	lua_Object modeObj = lua_getparam(4);
	/* lua_Object paramObj = */ lua_getparam(5);

	if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
		return;

	Actor *actor = getactor(actorObj);

	if (!lua_isstring(choreObj) || !lua_isstring(costumeObj))
		lua_pushnil();

	bool mode = false;
	// float param = 0.0;

	if (!lua_isnil(modeObj)) {
		if (lua_getnumber(modeObj) != 0.0)
			mode = true;
		//if (!lua_isnil(paramObj))
		//	if (lua_isnumber(paramObj))
		//		param = lua_getnumber(paramObj);
	}

	const char *choreName = lua_getstring(choreObj);

	const char *costumeName = lua_getstring(costumeObj);
	Costume *costume;
	// If a new wear chore is set and it uses a different costume than the
	// current one and neither of them is the shadow costume stop all active
	// chores and remove the old costume before setting the new one.
	//
	// This is necessary, because always the last costume on the stack, even
	// if it is not active, is returned by getCurrentCostume(). This would
	// cause an issue if the costumes would have different joints and the lua
	// code would consider a different costume active than the C code.
	if (0 == strncmp("wear_", choreName, 5)) {
		if (0 != strncmp("fx/dumbshadow.cos", costumeName, 17)) {
			if (actor->getCurrentCostume() != NULL &&
			    actor->getCurrentCostume()->getFilename() != "fx/dumbshadow.cos" &&
			    actor->getCurrentCostume()->getFilename().compareToIgnoreCase(costumeName) != 0) {
				actor->stopAllChores();
				actor->setRestChore(-1, NULL);
				actor->setWalkChore(-1, NULL);
				actor->setTurnChores(-1, -1, NULL);
				actor->setMumbleChore(-1, NULL);
				actor->popCostume();
			}
		}
	}
	if (!findCostume(costumeObj, actor, &costume))
		return;

	EMIChore *chore = (EMIChore *)costume->getChore(choreName);
	if (0 == strncmp("wear_", choreName, 5)) {
		actor->setLastWearChore(costume->getChoreId(choreName), costume);
	}

	if (mode) {
		costume->playChoreLooping(choreName);
	} else {
		costume->playChore(choreName);
	}
	if (chore) {
		lua_pushusertag(chore->getId(), MKTAG('C','H','O','R'));
	} else {
		lua_pushnil();
	}

}