From b501ba67e30c509f58873c2c76d2091bf5b8f0a6 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Thu, 6 Mar 2014 22:31:22 +0100 Subject: [PATCH] Respect more nodes' active status: PATH_STEAM, PATH_WARP, PATH_RADARHIDE, PATH_WATERBUBBLE, PATH_ZOOM. These nodes will no longer do their thing if active is set to false. node_[is|set]EffectOn() is now an alias for the node_[is|set]Active() functions. Also add getMaxCameraValues() Lua function. --- Aquaria/Avatar.cpp | 4 ++-- Aquaria/Entity.cpp | 2 +- Aquaria/Game.cpp | 2 +- Aquaria/MiniMapRender.cpp | 2 +- Aquaria/Path.cpp | 5 ++--- Aquaria/Path.h | 3 --- Aquaria/ScriptInterface.cpp | 37 +++++++++++++++++++------------------ Aquaria/SteamRender.cpp | 2 +- 8 files changed, 27 insertions(+), 30 deletions(-) diff --git a/Aquaria/Avatar.cpp b/Aquaria/Avatar.cpp index 1928d7f..d8f35f7 100644 --- a/Aquaria/Avatar.cpp +++ b/Aquaria/Avatar.cpp @@ -7200,10 +7200,10 @@ bool Avatar::checkWarpAreas() { bool warp = false; Path *p = dsq->game->getPath(i); - if (!p->nodes.empty()) + if (p && p->active && !p->nodes.empty()) { PathNode *n = &p->nodes[0]; - if (p && n) + if (n) { Vector backPos; if (!p->vox.empty()) diff --git a/Aquaria/Entity.cpp b/Aquaria/Entity.cpp index a98092d..d89a13d 100644 --- a/Aquaria/Entity.cpp +++ b/Aquaria/Entity.cpp @@ -2193,7 +2193,7 @@ bool Entity::isUnderWater(const Vector &override) Path *p = dsq->game->getNearestPath(position, PATH_WATERBUBBLE); - if (p != 0 && p->isCoordinateInside(position, collideRadius)) + if (p && p->active && p->isCoordinateInside(position, collideRadius)) { waterBubble = p; return true; diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index 7eee627..92137cc 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -5736,7 +5736,7 @@ int game_collideParticle(Vector pos) if (!aboveWaterLine) { Path *p = dsq->game->getNearestPath(pos, PATH_WATERBUBBLE); - if (p) + if (p && p->active) { if (p->isCoordinateInside(pos)) { diff --git a/Aquaria/MiniMapRender.cpp b/Aquaria/MiniMapRender.cpp index c7be281..5e0d24b 100644 --- a/Aquaria/MiniMapRender.cpp +++ b/Aquaria/MiniMapRender.cpp @@ -273,7 +273,7 @@ void MiniMapRender::onUpdate(float dt) { for (Path *p = dsq->game->getFirstPathOfType(PATH_RADARHIDE); p; p = p->nextOfType) { - if (p->isCoordinateInside(dsq->game->avatar->position)) + if (p->active && p->isCoordinateInside(dsq->game->avatar->position)) { radarHide = true; break; diff --git a/Aquaria/Path.cpp b/Aquaria/Path.cpp index cd34918..3b1bc1f 100644 --- a/Aquaria/Path.cpp +++ b/Aquaria/Path.cpp @@ -25,7 +25,6 @@ Path::Path() { addType(SCO_PATH); localWarpType = LOCALWARP_NONE; - effectOn = true; time = 0; naijaIn = false; amount = 0; @@ -538,7 +537,7 @@ void Path::update(float dt) } } } - if (pathType == PATH_ZOOM && dsq->game->avatar) + if (active && pathType == PATH_ZOOM && dsq->game->avatar) { if (isCoordinateInside(dsq->game->avatar->position)) { @@ -555,7 +554,7 @@ void Path::update(float dt) } } - if (pathType == PATH_STEAM && !dsq->game->isWorldPaused() && effectOn) + if (active && pathType == PATH_STEAM && !dsq->game->isWorldPaused()) { animOffset -= 1000*0.00002f; diff --git a/Aquaria/Path.h b/Aquaria/Path.h index b86b2f2..203ee92 100644 --- a/Aquaria/Path.h +++ b/Aquaria/Path.h @@ -90,8 +90,6 @@ public: void setActive(bool v); bool action(int id, int state); - void setEffectOn(bool on) { effectOn = on; } - PathNode *getPathNode(int idx); bool isCoordinateInside(const Vector &pos, int rad=0); @@ -142,7 +140,6 @@ public: std::string gem; - bool effectOn; bool spiritFreeze; bool pauseFreeze; diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 82e6e5e..c50d48c 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -693,6 +693,7 @@ static void safePath(lua_State *L, const std::string& path) #define luaReturnStr(str) do {lua_pushstring(L, (str)); return 1;} while(0) #define luaReturnVec2(x,y) do {lua_pushnumber(L, (x)); lua_pushnumber(L, (y)); return 2;} while(0) #define luaReturnVec3(x,y,z) do {lua_pushnumber(L, (x)); lua_pushnumber(L, (y)); lua_pushnumber(L, (z)); return 3;} while(0) +#define luaReturnVec4(x,y,z,w) do {lua_pushnumber(L, (x)); lua_pushnumber(L, (y)); lua_pushnumber(L, (z)); lua_pushnumber(L, (w)); return 4;} while(0) #define luaReturnNil() return 0; // Set the global "v" to the instance's local variable table. Must be @@ -4754,6 +4755,12 @@ luaFunc(node_setActive) luaReturnNil(); } +luaFunc(node_isActive) +{ + Path *p = path(L); + luaReturnBool(p ? p->active : false); +} + luaFunc(node_setCursorActivation) { Path *p = path(L); @@ -5516,7 +5523,7 @@ luaFunc(entity_isInRect) { Entity *e = entity(L); bool v= false; - int x1, y1, x2, y2; + float x1, y1, x2, y2; x1 = lua_tonumber(L, 2); y1 = lua_tonumber(L, 3); x2 = lua_tonumber(L, 4); @@ -7203,20 +7210,6 @@ luaFunc(getEntityByID) luaReturnPtr(found); } -luaFunc(node_setEffectOn) -{ - Path *p = path(L, 1); - if (p) - p->setEffectOn(getBool(L, 2)); - luaReturnNil(); -} - -luaFunc(node_isEffectOn) -{ - Path *p = path(L, 1); - luaReturnBool(p ? p->effectOn : false); -} - luaFunc(node_activate) { Path *p = path(L); @@ -7503,7 +7496,7 @@ luaFunc(toggleSteam) bool on = getBool(L, 1); for (Path *p = dsq->game->getFirstPathOfType(PATH_STEAM); p; p = p->nextOfType) { - p->setEffectOn(on); + p->setActive(on); } luaReturnBool(on); } @@ -8610,6 +8603,11 @@ luaFunc(getUserInputString) luaReturnStr(dsq->getUserInputString(getString(L, 1), getString(L, 2), true).c_str()); } +luaFunc(getMaxCameraValues) +{ + luaReturnVec4(dsq->game->cameraMin.x, dsq->game->cameraMin.y, dsq->game->cameraMax.x, dsq->game->cameraMax.y); +} + luaFunc(inv_isFull) { @@ -9426,6 +9424,7 @@ static const struct { luaRegister(findPath), luaRegister(castLine), luaRegister(getUserInputString), + luaRegister(getMaxCameraValues), luaRegister(isFlag), @@ -9640,8 +9639,6 @@ static const struct { luaRegister(node_getContent), luaRegister(node_getAmount), luaRegister(node_getSize), - luaRegister(node_setEffectOn), - luaRegister(node_isEffectOn), luaRegister(node_getShape), luaRegister(toggleSteam), @@ -9674,6 +9671,7 @@ static const struct { luaRegister(entity_changeHealth), luaRegister(node_setActive), + luaRegister(node_isActive), luaRegister(setSceneColor), @@ -9885,6 +9883,9 @@ static const struct { {"bone_setColor", l_bone_color}, + {"node_setEffectOn", l_node_setActive}, + {"node_isEffectOn", l_node_isActive}, + }; //============================================================================================ diff --git a/Aquaria/SteamRender.cpp b/Aquaria/SteamRender.cpp index 6502670..7273ede 100644 --- a/Aquaria/SteamRender.cpp +++ b/Aquaria/SteamRender.cpp @@ -46,7 +46,7 @@ void SteamRender::onRender() for (Path *p = dsq->game->getFirstPathOfType(PATH_STEAM); p; p = p->nextOfType) { - if (p->effectOn) + if (p->active) { int w2 = p->rect.getWidth()/2;