diff --git a/Aquaria/Avatar.cpp b/Aquaria/Avatar.cpp index 43d334c..6642d42 100644 --- a/Aquaria/Avatar.cpp +++ b/Aquaria/Avatar.cpp @@ -7127,7 +7127,7 @@ void Avatar::onUpdate(float dt) if(!core->particlesPaused && elementEffectMult > 0) { - ElementUpdateList& elems = dsq->game->elementUpdateList; + ElementUpdateList& elems = dsq->game->elementInteractionList; for (ElementUpdateList::iterator it = elems.begin(); it != elems.end(); ++it) { (*it)->doInteraction(this, elementEffectMult, 16); diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index a331cc6..fe26abb 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -4829,7 +4829,12 @@ void DSQ::modifyDt(float &dt) if (isDeveloperKeys()) { if (core->getKeyState(KEY_G)) - dt *= 4; + { + if(core->getShiftState()) + dt *= 10; + else + dt *= 4; + } else if (core->getKeyState(KEY_F)) { if (core->getShiftState()) diff --git a/Aquaria/Element.cpp b/Aquaria/Element.cpp index 9c8cc51..c18bac7 100644 --- a/Aquaria/Element.cpp +++ b/Aquaria/Element.cpp @@ -84,12 +84,8 @@ void Element::doInteraction(Entity *ent, float mult, float touchWidth) eff->hitPerc = hitPerc; eff->touchVel = ent->vel; eff->effectMult = mult; - return; } } - //eff->touchVel = Vector(0, 0); - //eff->hitPerc = 0; - eff->touching = false; } void Element::updateEffects(float dt) @@ -110,6 +106,7 @@ void Element::updateEffects(float dt) if (eff->touching) { + eff->touching = false; float ramp = eff->touchVel.getLength2D()/800.0f; if (ramp < 0) ramp = 0; if (ramp > 1) ramp = 1; diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index 80920da..1b35de4 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -5910,22 +5910,14 @@ void Game::rebuildElementUpdateList() elementUpdateList.clear(); elementInteractionList.clear(); for (int i = 0; i < dsq->getNumElements(); i++) - //for (int i = LR_ELEMENTS1; i <= LR_ELEMENTS8; i++) { - //RenderObjectLayer *rl = dsq->getRenderObjectLayer(i); Element *e = dsq->getElement(i); - if (e && e->layer >= LR_ELEMENTS1 && e->layer <= LR_ELEMENTS8) - { - if (e->getElementEffectIndex() != -1) - { - elementUpdateList.push_back(e); - } - ElementEffect ee = dsq->getElementEffectByIndex(e->getElementEffectIndex()); - if(ee.type == EFX_WAVY) - { - elementInteractionList.push_back(e); - } - } + const int eeidx = e->getElementEffectIndex(); + if (eeidx != -1 && e->layer >= LR_ELEMENTS1 && e->layer <= LR_ELEMENTS8) + elementUpdateList.push_back(e); + ElementEffect ee = dsq->getElementEffectByIndex(eeidx); + if(ee.type == EFX_WAVY) + elementInteractionList.push_back(e); } } @@ -6460,18 +6452,9 @@ void Game::applyState() } #endif - worldMapRender = 0; - dsq->continuity.worldMap.revealMap(sceneToLoad); - - debugLog("Creating WorldMapRender"); - if(dsq->mod.isActive() && dsq->mod.mapRevealMethod != REVEAL_UNSPECIFIED) - WorldMapRender::setRevealMethod(dsq->mod.mapRevealMethod); - else - WorldMapRender::setRevealMethod((WorldMapRevealMethod)dsq->user.video.worldMapRevealMethod); - - worldMapRender = new WorldMapRender; - addRenderObject(worldMapRender, LR_WORLDMAP); - +/* + if (liFlag == 100) + */ if (verbose) debugLog("Creating Avatar"); avatar = new Avatar(); @@ -6535,6 +6518,8 @@ void Game::applyState() if (verbose) debugLog("...Done"); backupSceneColor = sceneColor; + dsq->continuity.worldMap.revealMap(sceneName); + colorTest(); if (!warpAreaType.empty()) @@ -6663,6 +6648,18 @@ void Game::applyState() timerText->followCamera = 1; addRenderObject(timerText, LR_MINIMAP); + worldMapRender = 0; + + if(dsq->mod.isActive() && dsq->mod.mapRevealMethod != REVEAL_UNSPECIFIED) + WorldMapRender::setRevealMethod(dsq->mod.mapRevealMethod); + else + WorldMapRender::setRevealMethod((WorldMapRevealMethod)dsq->user.video.worldMapRevealMethod); + + worldMapRender = new WorldMapRender; + addRenderObject(worldMapRender, LR_WORLDMAP); + // to hide minimap + //miniMapRender->position += Vector(800,0); + sceneToLoad=""; if (!fromScene.empty()) @@ -10819,6 +10816,7 @@ void Game::removeState() core->particlesPaused = false; elementUpdateList.clear(); + elementInteractionList.clear(); dsq->setCursor(CURSOR_NORMAL); dsq->darkLayer.toggle(0); diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 75ff6b6..232e143 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -38,6 +38,7 @@ extern "C" #include "AfterEffect.h" #include "PathFinding.h" #include +#include "Gradient.h" #include "../BBGE/MathFunctions.h" @@ -891,6 +892,7 @@ MakeTypeCheckFunc(isNode, SCO_PATH); MakeTypeCheckFunc(isObject, SCO_RENDEROBJECT); MakeTypeCheckFunc(isEntity, SCO_ENTITY) MakeTypeCheckFunc(isScriptedEntity, SCO_SCRIPTED_ENTITY) +MakeTypeCheckFunc(isBone, SCO_BONE) MakeTypeCheckFunc(isShot, SCO_SHOT) MakeTypeCheckFunc(isWeb, SCO_WEB) MakeTypeCheckFunc(isIng, SCO_INGREDIENT) @@ -1180,6 +1182,7 @@ luaFunc(obj_addChild) RenderObject *r = robj(L); RenderObject *which = robj(L, 2); bool takeOwnership = getBool(L, 3); + bool front = getBool(L, 4); if (r && which) { if (takeOwnership) @@ -1189,7 +1192,7 @@ luaFunc(obj_addChild) dsq->getState(dsq->game->name)->removeRenderObjectFromList(which); which->setStateDataObject(NULL); core->removeRenderObject(which, Core::DO_NOT_DESTROY_RENDER_OBJECT); - r->addChild(which, PM_POINTER); + r->addChild(which, PM_POINTER, RBP_NONE, front ? CHILD_FRONT : CHILD_BACK); } else r->addChild(which, PM_STATIC); @@ -5524,7 +5527,7 @@ luaFunc(entity_doElementInteraction) if (!touchWidth) touchWidth = 16; - ElementUpdateList& elems = dsq->game->elementUpdateList; + ElementUpdateList& elems = dsq->game->elementInteractionList; for (ElementUpdateList::iterator it = elems.begin(); it != elems.end(); ++it) { (*it)->doInteraction(e, mult, touchWidth); @@ -8974,6 +8977,19 @@ luaFunc(learnRecipe) luaReturnNil(); } +luaFunc(setBGGradient) +{ + if(!dsq->game->grad) + dsq->game->createGradient(); + Vector c1(lua_tonumber(L, 1), lua_tonumber(L, 2), lua_tonumber(L, 3)); + Vector c2(lua_tonumber(L, 4), lua_tonumber(L, 5), lua_tonumber(L, 6)); + if(getBool(L, 7)) + dsq->game->grad->makeHorizontal(c1, c2); + else + dsq->game->grad->makeVertical(c1, c2); + luaReturnNil(); +} + luaFunc(createDebugText) { DebugFont *txt = new DebugFont(lua_tointeger(L, 2), getString(L, 1)); @@ -10080,6 +10096,7 @@ static const struct { luaRegister(getScreenVirtualSize), luaRegister(isMiniMapCursorOkay), luaRegister(isShuttingDownGameState), + luaRegister(setBGGradient), luaRegister(inv_isFull), luaRegister(inv_getMaxAmount), @@ -10121,6 +10138,7 @@ static const struct { luaRegister(isObject), luaRegister(isEntity), luaRegister(isScriptedEntity), + luaRegister(isBone), luaRegister(isShot), luaRegister(isWeb), luaRegister(isIng), diff --git a/BBGE/Base.cpp b/BBGE/Base.cpp index 7cc5958..785e3fb 100644 --- a/BBGE/Base.cpp +++ b/BBGE/Base.cpp @@ -547,13 +547,13 @@ tinyxml2::XMLError readXML(const std::string& fn, tinyxml2::XMLDocument& doc) return err; } -tinyxml2::XMLDocument *readXML(const std::string& fn, tinyxml2::XMLError *perr /* = 0 */) +tinyxml2::XMLDocument *readXML(const std::string& fn, tinyxml2::XMLError *perr /* = 0 */, bool keepEmpty /* = false */) { tinyxml2::XMLDocument *doc = new tinyxml2::XMLDocument(); tinyxml2::XMLError err = readXML(fn, *doc); if(perr) *perr = err; - if(err != tinyxml2::XML_SUCCESS) + if(err != tinyxml2::XML_SUCCESS && !keepEmpty) { delete doc; doc = NULL; diff --git a/BBGE/Base.h b/BBGE/Base.h index 8471dd4..7e51583 100644 --- a/BBGE/Base.h +++ b/BBGE/Base.h @@ -206,7 +206,7 @@ bool exists(const std::string &f, bool makeFatal = false, bool skipVFS = false); void errorLog(const std::string &s); void debugLog(const std::string &s); char *readFile(const std::string& path, unsigned long *size_ret = 0); -tinyxml2::XMLDocument *readXML(const std::string& fn, tinyxml2::XMLError *perr = 0); +tinyxml2::XMLDocument *readXML(const std::string& fn, tinyxml2::XMLError *perr = 0, bool keepEmpty = false); tinyxml2::XMLError readXML(const std::string& fn, tinyxml2::XMLDocument& doc); char *readCompressedFile(std::string path, unsigned long *size_ret = 0); void forEachFile(std::string path, std::string type, void callback(const std::string &filename, intptr_t param), intptr_t param); diff --git a/BBGE/RenderObject.cpp b/BBGE/RenderObject.cpp index abb0c16..322c2aa 100644 --- a/BBGE/RenderObject.cpp +++ b/BBGE/RenderObject.cpp @@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "MathFunctions.h" #include +#include bool RenderObject::renderCollisionShape = false; int RenderObject::lastTextureApplied = 0; @@ -467,13 +468,29 @@ void RenderObject::toggleCull(bool value) void RenderObject::moveToFront() { - if (layer != -1) + if(RenderObject *p = parent) + { + if(p->children.size() && p->children[0] != this) + { + p->removeChild(this); + p->addChild(this, (ParentManaged)this->pm, RBP_NONE, CHILD_FRONT); + } + } + else if (layer != -1) core->renderObjectLayers[this->layer].moveToFront(this); } void RenderObject::moveToBack() { - if (layer != -1) + if(RenderObject *p = parent) + { + if(p->children.size() && p->children[p->children.size()-1] != this) + { + p->removeChild(this); + p->addChild(this, (ParentManaged)this->pm, RBP_NONE, CHILD_BACK); + } + } + else if (layer != -1) core->renderObjectLayers[this->layer].moveToBack(this); } diff --git a/BBGE/SkeletalSprite.cpp b/BBGE/SkeletalSprite.cpp index 85dc918..069cd86 100644 --- a/BBGE/SkeletalSprite.cpp +++ b/BBGE/SkeletalSprite.cpp @@ -34,13 +34,13 @@ std::string SkeletalSprite::secondaryAnimationPath = ""; static std::map skelCache; -static XMLDocument *_retrieveSkeletalXML(const std::string& name) +static XMLDocument *_retrieveSkeletalXML(const std::string& name, bool keepEmpty) { std::map::iterator it = skelCache.find(name); if(it != skelCache.end()) return it->second; - XMLDocument *doc = readXML(name); + XMLDocument *doc = readXML(name, NULL, keepEmpty); if(doc) skelCache[name] = doc; @@ -49,6 +49,8 @@ static XMLDocument *_retrieveSkeletalXML(const std::string& name) void SkeletalSprite::clearCache() { + for(std::map::iterator it = skelCache.begin(); it != skelCache.end(); ++it) + delete it->second; skelCache.clear(); } @@ -869,7 +871,7 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn) } int i = 0; - XMLDocument *xml = _retrieveSkeletalXML(file); + XMLDocument *xml = _retrieveSkeletalXML(file, true); xml->Clear(); XMLElement *animationLayers = xml->NewElement("AnimationLayers"); @@ -1179,10 +1181,15 @@ void SkeletalSprite::loadSkin(const std::string &fn) if (!exists(file)) { - errorLog("Could not load skin[" + file + "]"); + errorLog("Could not load skin[" + file + "] - File not found."); + return; + } + XMLDocument *d = _retrieveSkeletalXML(file, false); + if(!d) + { + errorLog("Could not load skin[" + file + "] - Malformed XML."); return; } - XMLDocument *d = _retrieveSkeletalXML(file); XMLElement *bonesXml = d->FirstChildElement("Bones"); if (bonesXml) @@ -1315,7 +1322,7 @@ void SkeletalSprite::loadSkeletal(const std::string &fn) file = core->adjustFilenameCase(file); - XMLDocument *xml = _retrieveSkeletalXML(file); + XMLDocument *xml = _retrieveSkeletalXML(file, false); if(!xml) { filenameLoaded = ""; diff --git a/ExternalLibs/SDL2/lib/win32/SDL2.lib b/ExternalLibs/SDL2/lib/win32/SDL2.lib index 83f0a5f..45e87d3 100644 Binary files a/ExternalLibs/SDL2/lib/win32/SDL2.lib and b/ExternalLibs/SDL2/lib/win32/SDL2.lib differ diff --git a/ExternalLibs/SDL2/lib/win32/SDL2main.lib b/ExternalLibs/SDL2/lib/win32/SDL2main.lib index 2019eea..f77c1dc 100644 Binary files a/ExternalLibs/SDL2/lib/win32/SDL2main.lib and b/ExternalLibs/SDL2/lib/win32/SDL2main.lib differ diff --git a/files/scripts/entities/predatorytunicate.lua b/files/scripts/entities/predatorytunicate.lua index b6f6871..e4f9a20 100644 --- a/files/scripts/entities/predatorytunicate.lua +++ b/files/scripts/entities/predatorytunicate.lua @@ -143,27 +143,28 @@ function update(me, dt) entity_setState(me, STATE_IDLE) end ]]-- - - if entity_isState(me, STATE_TRAP) and v.trappedEnt ~= 0 then - entity_setPosition(v.trappedEnt, v.hx, v.hy, 0.1) + + if v.trappedEnt ~= 0 then if entity_isDead(v.trappedEnt) then v.trappedEnt = 0 entity_setState(me, STATE_IDLE) - end - elseif entity_isState(me, STATE_TRAPPED) and v.trappedEnt ~= 0 then - entity_setPosition(v.trappedEnt, v.hx, v.hy) - v.hurtTimer = v.hurtTimer + dt - if v.hurtTimer > 1 then - if entity_getEntityType(v.trappedEnt) == ET_ENEMY then - entity_damage(v.trappedEnt, me, 2, DT_ENEMY_TRAP) - else - entity_damage(v.trappedEnt, me, 1, DT_ENEMY_TRAP) + elseif entity_isState(me, STATE_TRAP) then + entity_setPosition(v.trappedEnt, v.hx, v.hy, 0.1) + elseif entity_isState(me, STATE_TRAPPED) then + entity_setPosition(v.trappedEnt, v.hx, v.hy) + v.hurtTimer = v.hurtTimer + dt + if v.hurtTimer > 1 then + if entity_getEntityType(v.trappedEnt) == ET_ENEMY then + entity_damage(v.trappedEnt, me, 2, DT_ENEMY_TRAP) + else + entity_damage(v.trappedEnt, me, 1, DT_ENEMY_TRAP) + end + if entity_isDead(v.trappedEnt) then + v.trappedEnt = 0 + entity_setState(me, STATE_IDLE) + end + v.hurtTimer = 0 end - if entity_isDead(v.trappedEnt) then - v.trappedEnt = 0 - entity_setState(me, STATE_IDLE) - end - v.hurtTimer = 0 end end end diff --git a/files/scripts/entities/spinycrab.lua b/files/scripts/entities/spinycrab.lua index 3c56890..8ebab12 100644 --- a/files/scripts/entities/spinycrab.lua +++ b/files/scripts/entities/spinycrab.lua @@ -119,6 +119,9 @@ function enterState(me) quad_alpha(v.glow, 0, 3) bone_alpha(v.eyes, 0, 3) entity_animate(me, "runAway", -1) + elseif entity_isState(me, STATE_DEAD) then + quad_delete(v.glow) + v.glow = 0 end end