void Lua_V2::WalkActorToAvoiding() { lua_Object actorObj = lua_getparam(1); lua_Object actor2Obj = lua_getparam(2); lua_Object xObj = lua_getparam(3); lua_Object yObj = lua_getparam(4); lua_Object zObj = lua_getparam(5); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; if (!lua_isuserdata(actor2Obj) || lua_tag(actor2Obj) != MKTAG('A','C','T','R')) return; Math::Vector3d destVec; Actor *actor = getactor(actorObj); if (!lua_isnumber(xObj)) { if (!lua_isuserdata(xObj) || lua_tag(xObj) != MKTAG('A','C','T','R')) return; Actor *destActor = getactor(xObj); destVec = destActor->getPos(); } else { float x = lua_getnumber(xObj); float y = lua_getnumber(yObj); float z = lua_getnumber(zObj); destVec.set(x, y, z); } // TODO: Make this actually avoid the second actor actor->walkTo(destVec); }
void Lua_V2::AttachActor() { // Missing lua parts lua_Object attachedObj = lua_getparam(1); lua_Object actorObj = lua_getparam(2); lua_Object jointObj = lua_getparam(3); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A', 'C', 'T', 'R')) return; Actor *actor = getactor(actorObj); if (!actor) return; if (!lua_isuserdata(attachedObj) || lua_tag(attachedObj) != MKTAG('A', 'C', 'T', 'R')) return; Actor *attached = getactor(attachedObj); if (!attached) return; const char *joint = NULL; if (!lua_isnil(jointObj)) { joint = lua_getstring(jointObj); } attached->attachToActor(actor, joint); warning("Lua_V2::AttachActor: attaching %s to %s (on %s)", attached->getName().c_str(), actor->getName().c_str(), joint ? joint : "(none)"); g_emi->invalidateSortOrder(); }
void Lua_V2::SetActorMumblechore() { lua_Object actorObj = lua_getparam(1); lua_Object choreObj = lua_getparam(2); lua_Object costumeObj = lua_getparam(3); Costume *costume; int chore; if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R') || (!lua_isstring(choreObj) && !lua_isnil(choreObj))) { return; } Actor *actor = getactor(actorObj); if (!findCostume(costumeObj, actor, &costume)) return; if (lua_isnil(choreObj)) { chore = -1; } else { const char * choreStr = lua_getstring(choreObj); chore = costume->getChoreId(choreStr); } actor->setMumbleChore(chore, costume); }
void Lua_V2::SetActorTalkChore() { lua_Object actorObj = lua_getparam(1); lua_Object indexObj = lua_getparam(2); lua_Object choreObj = lua_getparam(3); lua_Object costumeObj = lua_getparam(4); Costume *costume; int chore; if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R') || !lua_isnumber(indexObj) || (!lua_isstring(choreObj) && !lua_isnil(choreObj))) { return; } int index = (int)lua_getnumber(indexObj); if (index < 1 || index > 16) return; Actor *actor = getactor(actorObj); if (!findCostume(costumeObj, actor, &costume)) return; if (lua_isnil(choreObj)) { chore = -1; } else { const char * choreStr = lua_getstring(choreObj); chore = costume->getChoreId(choreStr); } actor->setTalkChore(index, chore, costume); }
static void L2_SetActorLighting() { lua_Object actorObj = lua_getparam(1); lua_Object lightModeObj = lua_getparam(2); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); if (!actor) return; if (lua_isnil(lightModeObj) || !lua_isnumber(lightModeObj)) return; int lightMode = (int)lua_getnumber(lightModeObj); if (lightMode != 0) { if (lightMode == 1) { //FIXME actor-> warning("L2_SetActorLighting: case param 1(LIGHT_FASTDYN), actor: %s", actor->getName().c_str()); } else if (lightMode == 2) { //FIXME actor-> warning("L2_SetActorLighting: case param 2(LIGHT_NORMDYN), actor: %s", actor->getName().c_str()); } else { //FIXME actor-> warning("L2_SetActorLighting: case param %d(LIGHT_NONE), actor: %s", lightMode, actor->getName().c_str()); } } else { //FIXME actor-> warning("L2_SetActorLighting: case param 0(LIGHT_STATIC), actor: %s", actor->getName().c_str()); } }
void L1_IsActorInSector() { lua_Object actorObj = lua_getparam(1); lua_Object nameObj = lua_getparam(2); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; if (!lua_isstring(nameObj)) { lua_pushnil(); return; } Actor *actor = getactor(actorObj); const char *name = lua_getstring(nameObj); int numSectors = g_grim->getCurrScene()->getSectorCount(); for (int i = 0; i < numSectors; i++) { Sector *sector = g_grim->getCurrScene()->getSectorBase(i); if (strstr(sector->getName(), name)) { if (sector->isPointInSector(actor->getPos())) { lua_pushnumber(sector->getSectorId()); lua_pushstring(sector->getName()); lua_pushnumber(sector->getType()); return; } } } lua_pushnil(); }
static void L2_SetActorGlobalAlpha() { lua_Object actorObj = lua_getparam(1); // lua_Object alphaModeObj = lua_getparam(2); // lua_Object valueObj = lua_getparam(3); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); if (!actor) return; warning("L2_SetActorGlobalAlpha: actor: %s", actor->getName().c_str()); /* Only when actor has primitives if (!actor->primities) return; if (lua_isnumber(alphaModeObj) { int alphaMode = (int)lua_getnumber(alphaModeObj); if (!lua_isnil(valueObj) && lua_isstring(valueObj)) { // TODO: missing part } // TODO } */ }
void Lua_V2::PutActorInSet() { lua_Object actorObj = lua_getparam(1); lua_Object setObj = lua_getparam(2); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); if (!lua_isstring(setObj) && !lua_isnil(setObj)) { lua_pushnil(); return; } const char *set = lua_getstring(setObj); // FIXME verify adding actor to set if (!set) { actor->putInSet(""); lua_pushnil(); } else { if (!actor->isInSet(set)) { actor->putInSet(set); actor->playLastWearChore(); } lua_pushnumber(1.0); } }
void Lua_V2::SetActorTurnChores() { lua_Object actorObj = lua_getparam(1); lua_Object leftChoreObj = lua_getparam(2); lua_Object rightChoreObj = lua_getparam(3); lua_Object costumeObj = lua_getparam(4); Costume *costume; if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) { return; } else if (!lua_isnil(leftChoreObj) && !lua_isstring(leftChoreObj)) { return; } else if (!lua_isnil(rightChoreObj) && !lua_isstring(rightChoreObj)) { return; } Actor *actor = getactor(actorObj); if (!findCostume(costumeObj, actor, &costume)) return; if (!costume) { costume = actor->getCurrentCostume(); } int leftChore = costume->getChoreId(lua_getstring(leftChoreObj)); int rightChore = costume->getChoreId(lua_getstring(rightChoreObj)); actor->setTurnChores(leftChore, rightChore, costume); }
void Lua_V1::SetSoundPosition() { Math::Vector3d pos; int minVolume = 10; int maxVolume = 127; float someParam = 0; int argId = 1; lua_Object paramObj; if (g_grim->getCurrSet()) { g_grim->getCurrSet()->getSoundParameters(&minVolume, &maxVolume); } lua_Object nameObj = lua_getparam(argId++); if (!lua_isnumber(nameObj) && !lua_isstring(nameObj)) return; lua_Object actorObj = lua_getparam(argId++); if (lua_isuserdata(actorObj) && lua_tag(actorObj) == MKTAG('A','C','T','R')) { Actor *actor = getactor(actorObj); if (!actor) return; pos = actor->getPos(); } else if (lua_isnumber(actorObj)) { float x = lua_getnumber(actorObj); float y = lua_getnumber(argId++); float z = lua_getnumber(argId++); pos.set(x, y, z); } paramObj = (int)lua_getparam(argId++); if (lua_isnumber(paramObj)) { minVolume = (int)lua_getnumber(paramObj); if (minVolume > 127) minVolume = 127; } paramObj = lua_getparam(argId++); if (lua_isnumber(paramObj)) { maxVolume = (int)lua_getnumber(paramObj); if (maxVolume > 127) maxVolume = 127; else if (maxVolume < minVolume) maxVolume = minVolume; } paramObj = lua_getparam(argId++); if (lua_isnumber(paramObj)) { someParam = (int)lua_getnumber(paramObj); if (someParam < 0.0) someParam = 0.0; } if (g_grim->getCurrSet()) { if (lua_isnumber(nameObj)) error("SetSoundPosition: number is not yet supported"); else { const char *soundName = lua_getstring(nameObj); g_grim->getCurrSet()->setSoundPosition(soundName, pos, minVolume, maxVolume); } } }
void Lua_V2::SetActorCollisionMode() { lua_Object actorObj = lua_getparam(1); lua_Object modeObj = lua_getparam(2); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); assert(actor); int mode = (int)lua_getnumber(modeObj); Actor::CollisionMode m; switch (mode) { case Actor::CollisionOff: m = Actor::CollisionOff; break; case Actor::CollisionBox: m = Actor::CollisionBox; break; case Actor::CollisionSphere: m = Actor::CollisionSphere; break; default: warning("Lua_V2::SetActorCollisionMode(): wrong collisionmode: %d, using default 0", mode); m = Actor::CollisionOff; } actor->setCollisionMode(m); }
void Lua_V1::SayLine() { int vol = 127, buffer = 64, paramId = 1, x = -1, y = -1; bool background = true; const char *msgId = NULL;; Common::String msg; lua_Object paramObj = lua_getparam(paramId++); if ((lua_isuserdata(paramObj) && lua_tag(paramObj) == MKTAG('A','C','T','R')) || lua_isstring(paramObj) || lua_istable(paramObj)) { Actor *actor = NULL;//some_Actor, maybe some current actor if (lua_isuserdata(paramObj) && lua_tag(paramObj) == MKTAG('A','C','T','R')) { actor = getactor(paramObj); paramObj = lua_getparam(paramId++); } if (actor) { while (!lua_isnil(paramObj)) { if (!lua_isstring(paramObj) && !lua_isnumber(paramObj) && !lua_istable(paramObj)) break; if (lua_istable(paramObj)) parseSayLineTable(paramObj, &background, &vol, &buffer, &x, &y); else { if (lua_isnumber(paramObj)) background = false; else { msgId = lua_getstring(paramObj); } } paramObj = lua_getparam(paramId++); } actor->sayLine(msgId, background); //background, vol, pan, x, y } } }
void Lua_V2::GetActorPuckVector() { lua_Object actorObj = lua_getparam(1); lua_Object addObj = lua_getparam(2); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) { lua_pushnil(); return; } Actor *actor = getactor(actorObj); // Note: The wear chore of dumbshadow.cos is only started from Lua if // GetActorPuckVector returns a non-nil value. The original engine seems // to return nil for all actors that have never followed walkboxes. if (!actor || !actor->hasFollowedBoxes()) { lua_pushnil(); return; } Math::Vector3d result = actor->getPuckVector(); if (!lua_isnil(addObj)) result += actor->getPos(); lua_pushnumber(result.x()); lua_pushnumber(result.y()); lua_pushnumber(result.z()); }
void Lua_V2::SetActorLighting() { lua_Object actorObj = lua_getparam(1); lua_Object lightModeObj = lua_getparam(2); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); if (!actor) return; if (lua_isnil(lightModeObj) || !lua_isnumber(lightModeObj)) return; int lightMode = (int)lua_getnumber(lightModeObj); if (lightMode != 0) { if (lightMode == 1) { //FIXME actor-> warning("Lua_V2::SetActorLighting: case param 1(LIGHT_FASTDYN), actor: %s", actor->getName().c_str()); } else if (lightMode == 2) { //FIXME actor-> warning("Lua_V2::SetActorLighting: case param 2(LIGHT_NORMDYN), actor: %s", actor->getName().c_str()); } else { actor->setGlobalAlpha(0.0f); actor->setAlphaMode(Grim::Actor::AlphaReplace); } } else { //FIXME actor-> warning("Lua_V2::SetActorLighting: case param 0(LIGHT_STATIC), actor: %s", actor->getName().c_str()); } }
void Lua_V2::GetActorChores() { lua_Object actorObj = lua_getparam(1); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); Costume *costume = actor->getCurrentCostume(); lua_Object result = lua_createtable(); lua_pushobject(result); if (!costume) { lua_pushstring("count"); lua_pushnumber(0); lua_settable(); lua_pushobject(result); return; } int num = costume->getNumChores(); lua_pushstring("count"); lua_pushnumber(num); lua_settable(); for (int i = 0; i < num; ++i) { lua_pushobject(result); lua_pushnumber(i); lua_pushusertag(((EMIChore *)costume->getChore(i))->getId(), MKTAG('C','H','O','R')); lua_settable(); } lua_pushobject(result); }
void Lua_V2::GetActorSortOrder() { lua_Object actorObj = lua_getparam(1); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); lua_pushnumber(actor->getSortOrder()); }
void Lua_V2::GetActorWalkRate() { lua_Object actorObj = lua_getparam(1); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); // const below only differ from grim lua_pushnumber(actor->getWalkRate() * 0.3048780560493469); }
void Lua_V1::ShutUpActor() { lua_Object actorObj = lua_getparam(1); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); if (actor) actor->shutUp(); }
void Lua_V2::PutActorInOverworld() { lua_Object actorObj = lua_getparam(1); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); actor->setInOverworld(true); }
void Lua_V2::ActorStopMoving() { lua_Object actorObj = lua_getparam(1); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); warning("Lua_V2::ActorStopMoving, actor: %s", actor->getName().c_str()); // FIXME: implement missing rest part of code }
void Lua_V2::RemoveActorFromOverworld() { lua_Object actorObj = lua_getparam(1); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); if (!actor) return; actor->setInOverworld(false); }
static void L2_PutActorInOverworld() { lua_Object actorObj = lua_getparam(1); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); warning("L2_PutActorInOverworld, actor: %s", actor->getName().c_str()); // FIXME: implement missing func //actor->func(); }
void Lua_V2::SetActorLocalAlpha() { lua_Object actorObj = lua_getparam(1); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); if (!actor) return; // FIXME: implement missing code warning("Lua_V2::SetActorLocalAlpha: stub, actor: %s", actor->getName().c_str()); }
void Lua_V2::SetActorCollisionScale() { lua_Object actorObj = lua_getparam(1); lua_Object scaleObj = lua_getparam(2); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); assert(actor); float scale = lua_getnumber(scaleObj); actor->setCollisionScale(scale); }
static void L2_UnloadActor() { lua_Object actorObj = lua_getparam(1); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); if (!actor) return; warning("L2_UnloadActor: actor: %s", actor->getName().c_str()); // FIXME actor->func(); }
void Lua_V2::UnloadActor() { lua_Object actorObj = lua_getparam(1); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); if (!actor) return; g_grim->invalidateActiveActorsList(); g_grim->immediatelyRemoveActor(actor); delete actor; }
void Lua_V2::SetActorWalkRate() { lua_Object actorObj = lua_getparam(1); lua_Object rateObj = lua_getparam(2); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; if (!lua_isnumber(rateObj)) return; Actor *actor = getactor(actorObj); float rate = lua_getnumber(rateObj); // const below only differ from grim actor->setWalkRate(rate * 3.279999971389771); }
void Lua_V2::DetachActor() { // Missing lua parts lua_Object attachedObj = lua_getparam(1); if (!lua_isuserdata(attachedObj) || lua_tag(attachedObj) != MKTAG('A','C','T','R')) return; Actor *attached = getactor(attachedObj); if (!attached) return; warning("Lua_V2::DetachActor: detaching %s from parent actor", attached->getName().c_str()); attached->detach(); }
void Lua_V2::ActorStopMoving() { lua_Object actorObj = lua_getparam(1); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); actor->stopWalking(); // FIXME: Also stop turning? warning("Lua_V2::ActorStopMoving, actor: %s", actor->getName().c_str()); // FIXME: Inspect the rest of the code to see if there's anything else missing }
void Lua_V2::StopActorChores() { lua_Object actorObj = lua_getparam(1); // Guesswork for boolean parameter bool ignoreLoopingChores = getbool(2); if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) return; Actor *actor = getactor(actorObj); if (!actor) return; actor->stopAllChores(ignoreLoopingChores); }