mirror of
https://github.com/glest/glest-source.git
synced 2025-02-24 19:52:25 +01:00
lua commands to shake the cam
-- camera-distance-affected=false shakeCamera(int shakeIntensity, int shakeDuration) -- camera-distance-affected=true shakeCameraOnUnit(int shakeIntensity, int shakeDuration , int UnitId)
This commit is contained in:
parent
341c7ce46f
commit
70e01d5e0b
@ -248,6 +248,8 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro
|
||||
luaScript.registerFunction(DisplayFormattedLangText, "displayFormattedLangText");
|
||||
luaScript.registerFunction(clearDisplayText, "clearDisplayText");
|
||||
luaScript.registerFunction(setCameraPosition, "setCameraPosition");
|
||||
luaScript.registerFunction(shakeCamera, "shakeCamera");
|
||||
luaScript.registerFunction(shakeCameraOnUnit, "shakeCameraOnUnit");
|
||||
luaScript.registerFunction(createUnit, "createUnit");
|
||||
luaScript.registerFunction(createUnitNoSpacing, "createUnitNoSpacing");
|
||||
luaScript.registerFunction(destroyUnit, "destroyUnit");
|
||||
@ -1025,6 +1027,17 @@ void ScriptManager::setCameraPosition(const Vec2i &pos){
|
||||
gameCamera->centerXZ(pos.x, pos.y);
|
||||
}
|
||||
|
||||
void ScriptManager::shakeCamera(int shakeIntensity, int shakeDuration, bool cameraDistanceAffected, int unitId){
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
if (cameraDistanceAffected) {
|
||||
Unit *unit = world->findUnitById(unitId);
|
||||
gameCamera->shake(shakeDuration, shakeIntensity,cameraDistanceAffected, unit->getCurrVector());
|
||||
} else {
|
||||
gameCamera->shake(shakeDuration, shakeIntensity,cameraDistanceAffected, Vec3f(0.f,0.f,0.f));
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptManager::createUnit(const string &unitName, int factionIndex, Vec2i pos){
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] unit [%s] factionIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,unitName.c_str(),factionIndex);
|
||||
world->createUnit(unitName, factionIndex, pos);
|
||||
@ -2185,6 +2198,48 @@ int ScriptManager::setCameraPosition(LuaHandle* luaHandle){
|
||||
return luaArguments.getReturnCount();
|
||||
}
|
||||
|
||||
int ScriptManager::shakeCamera(LuaHandle* luaHandle){
|
||||
LuaArguments luaArguments(luaHandle);
|
||||
|
||||
try {
|
||||
thisScriptManager->shakeCamera(luaArguments.getInt(-2),luaArguments.getInt(-1),false,0);
|
||||
}
|
||||
catch(const megaglest_runtime_error &ex) {
|
||||
char szErrBuf[8096]="";
|
||||
snprintf(szErrBuf,8096,"In [%s::%s %d]",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
string sErrBuf = string(szErrBuf) + string("\nThe game may no longer be stable!\nerror [") + string(ex.what()) + string("]\n");
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,sErrBuf.c_str());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,sErrBuf.c_str());
|
||||
|
||||
thisScriptManager->addMessageToQueue(ScriptManagerMessage(sErrBuf.c_str(), "error",-1,-1,true));
|
||||
thisScriptManager->onMessageBoxOk(false);
|
||||
}
|
||||
|
||||
return luaArguments.getReturnCount();
|
||||
}
|
||||
|
||||
int ScriptManager::shakeCameraOnUnit(LuaHandle* luaHandle){
|
||||
LuaArguments luaArguments(luaHandle);
|
||||
|
||||
try {
|
||||
thisScriptManager->shakeCamera(luaArguments.getInt(-3),luaArguments.getInt(-2),true,luaArguments.getInt(-1));
|
||||
}
|
||||
catch(const megaglest_runtime_error &ex) {
|
||||
char szErrBuf[8096]="";
|
||||
snprintf(szErrBuf,8096,"In [%s::%s %d]",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
string sErrBuf = string(szErrBuf) + string("\nThe game may no longer be stable!\nerror [") + string(ex.what()) + string("]\n");
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,sErrBuf.c_str());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,sErrBuf.c_str());
|
||||
|
||||
thisScriptManager->addMessageToQueue(ScriptManagerMessage(sErrBuf.c_str(), "error",-1,-1,true));
|
||||
thisScriptManager->onMessageBoxOk(false);
|
||||
}
|
||||
|
||||
return luaArguments.getReturnCount();
|
||||
}
|
||||
|
||||
int ScriptManager::createUnit(LuaHandle* luaHandle) {
|
||||
LuaArguments luaArguments(luaHandle);
|
||||
|
||||
|
@ -278,6 +278,7 @@ private:
|
||||
void DisplayFormattedText(const char *fmt,...);
|
||||
void DisplayFormattedLangText(const char *fmt,...);
|
||||
void setCameraPosition(const Vec2i &pos);
|
||||
void shakeCamera(int shakeIntensity, int shakeDuration, bool cameraDistanceAffected, int unitId);
|
||||
void createUnit(const string &unitName, int factionIndex, Vec2i pos);
|
||||
void createUnitNoSpacing(const string &unitName, int factionIndex, Vec2i pos);
|
||||
|
||||
@ -441,6 +442,8 @@ private:
|
||||
static int DisplayFormattedLangText(LuaHandle* luaHandle);
|
||||
static int clearDisplayText(LuaHandle* luaHandle);
|
||||
static int setCameraPosition(LuaHandle* luaHandle);
|
||||
static int shakeCamera(LuaHandle* luaHandle);
|
||||
static int shakeCameraOnUnit(LuaHandle* luaHandle);
|
||||
static int createUnit(LuaHandle* luaHandle);
|
||||
static int createUnitNoSpacing(LuaHandle* luaHandle);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user